Jump to content

How to handle single instance stuff?


Guest mcMike

Recommended Posts

Guest mcMike

Hello,

Do I have to handle single-instance myself or will the framework/os do it for me? (I am using MFC on wm5 target).

Also I realised that when user switch to homescreen from app and then back there seems no redrawing of the screen? Even simple wizard-MFC dialog app can't handle that "automaticly". What is the correct way to handle it?

Thanks

Link to comment
Share on other sites

Guest mgama

Yes, MFC apps have issues. I haven't investigated that repainting issue yet, but I'm guessing an Invalidate() on the main window in response to the appropriate WM_ message would do the trick... again, just a guess, and I'm not sure which WM_ message you would need to listen for. I need to look into it more for my own app, but too many other things on my plate right now.

Single instance

CreateMutex is your friend. In your App::InitInstance() function, before you display your dialog, add the following code.

// limit us to a single instance.

HANDLE mymutex = CreateMutexW(NULL, TRUE, TEXT("SOME_UNIQUE_STRING_TO_IDENTIFY_YOUR_APP"));

if (!mymutex)

  return FALSE;

if (GetLastError() == ERROR_ALREADY_EXISTS)

  return FALSE;

Edited by mgama
Link to comment
Share on other sites

Guest mcMike
Yes, MFC apps have issues.  I haven't investigated that repainting issue yet, but I'm guessing an Invalidate() on the main window in response to the appropriate WM_ message would do the trick...  again, just a guess, and I'm not sure which WM_ message you would need to listen for.  I need to look into it more for my own app, but too many other things on my plate right now. 

Single instance

CreateMutex is your friend.  In your App::InitInstance() function, before you display your dialog, add the following code. 

// limit us to a single instance.

HANDLE mymutex = CreateMutexW(NULL, TRUE, TEXT("SOME_UNIQUE_STRING_TO_IDENTIFY_YOUR_APP"));

if (!mymutex)

  return FALSE;

if (GetLastError() == ERROR_ALREADY_EXISTS)

  return FALSE;

<{POST_SNAPBACK}>

Hello,

Thanks for the code. I am using OnSetFocus() currently with ShowWindow(SW_SHOW); and it seems to work but have some issues. If there is MessageBox() currently active in my app neither that nor anything else seem to work.

This kind sucks. How can this slip through testing and find itself in SDK / MFC8 ???

Another issue. Do you have simple guide how to enable debugging in device? WHAT certifcates and HOW needs to be applied?

I am using Qtek 8310 without any operator locks nor limits.

Thank You.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.