hi guys
I've two questions

first, i have few dialogs in my project and I'll use hotkeys on main to open the others dialogs
used registerhotkey with wm_hotkey

my code:
invoke RegisterHotKey,hWnd,065h,0, VK_X
.elseif uMsg == WM_HOTKEY
mov eax,wParam

    .if eax==065h
      mov hRichEdit,eax
invoke DialogBoxParam, hInstance, IDD_MD, NULL, addr md, NULL
invoke UnregisterHotKey,hWnd,065h
the prob., you know is I can use the hotkey more then one time and the dialog open and opens. 1x, 2x, 3x ...  :mad: :lol:

It's certainly easy but i'm more as few hours at that and i can't find a way :oops: :mad:

My second question is how can I disable the Alt-F4 "function" to termine my prog

I hope you can help me
Posted on 2006-04-08 17:58:26 by Sparkle
Create several global handles (one for each of the dialogs) when you create the dialogs, save the handle value, when the dialog is closed set the handle to NULL. Then, when you go to create a dialog, ONLY create the dialog if the stored handles value is NULL. This will ensure that only one of each dialog can be open at a time.

Bryant Keller
Posted on 2006-04-08 18:15:47 by Synfire
The demo you requested.
Posted on 2006-04-09 16:35:14 by Synfire
My second question is how can I disable the Alt-F4 "function" to termine my prog

ALT+F4 Posts a "WM_CLOSE" to your window. DefWindowProc destroys the window upon encountering WM_CLOSE and sends WM_DESTROY. Just handle the WM_CLOSE yourself, so that the DefWindowProc won't destroy your window. Please bear in mind that your application can stil be terminated in many other ways. Also make sure that you make a 'bypass' to WM_CLOSE, so that you can terminate your app cleanly.

1. initialize 'testvar' to 0
2. while handling WM_CLOSE: if (testvar == 0) then return 0 else DefWindowProc
3. a menu item 'exit' (or whatever) sets the 'testvar' to 1 and sends WM_CLOSE.

This way you'll disable Alt+F4, while still being able to terminate (using a menu item, for example).

There's also an easier and better looking way:
Just put CS_NOCLOSE flag when registering the window's class. CS_NOCLOSE disables the 'X' button and prevents it from sending WM_CLOSE. This is the preferred way (The one above was just to explain you how the WM_CLOSE and WM_DESTROY messages work ;) ).
Posted on 2006-04-10 00:15:17 by ti_mo_n
ok thanks its work now  :O

WM_HOTKEY is for global hotkeys (sys.wide)
gives a methode for local hotkeys, too? (for the application only)

i cant find nothing about that  :sad:

The process can be still terminate by taskmanager,... i know but most people using Alt+F4 to exit the app. which I dont find good
the terminating by taskm. (or other ways) are not bad when the app freez or something similar  :)
thats what I've searched  ;) thx
Posted on 2006-04-10 17:40:40 by Sparkle