I have a modal dialog box with many controls (edit box, combo box, buttons, up-down control, ...)
I want that when the user presses page-up or page-down my up-down control goes up and down
But my dialog procedure seems not to get VM_KEYDOWN message.

Why?

my code is like this


......
.elseif uMsg == WM_KEYDOWN
.if wParam == VK_NEXT
invoke MessageBox, hWnd, addr AppName, addr AppName, 0
.endif

.elseif uMsg == .....

Posted on 2003-12-23 05:51:00 by greenant
I think they are trapped by IsDialogMessage and used internally, like TAB, DOWN-ARROW etc...
Posted on 2003-12-23 06:19:03 by donkey
Is there a way (without sublcassing, hook, ...) to do what I want to do?
Posted on 2003-12-23 11:04:40 by greenant
Is there a way (without sublcassing, hook, ...) to do what I want to do?
yes, sure, but a bit lame, but works.

1. Define a user message

2. Trap this message before IsDialogMessage

3. SendMessage to your window message (subclassed or not)

if i remembered well, i was succeded with this way. Try first i will check this later.
Posted on 2003-12-23 14:05:53 by cakmak
My window is a modal dialog box. I don't call IsDialogMessage
Posted on 2003-12-23 14:07:19 by greenant
Sorry, i saw late. You are using modal. But if you may use modeless dialog you may do this easily. I meant,



while ( GetMessage( &messages, NULL, 0, 0 ) )
{
if ( messages.message == WM_KEYDOWN )
SendMessage ( hwnd, WM_KEYDOWN, messages.wParam, messages.lParam );

if ( !IsDialogMessage( hwnd, &messages ) )
{
TranslateMessage( &messages );
DispatchMessage( &messages );
}
}
return messages.wParam;
}



hmm this is C code. But who dares, all the same :)
Posted on 2003-12-23 14:11:18 by cakmak
Might want to try processing the WM_GETDLGCODE message first and see if that works, it is supoosed to be sent for each of the messages that IsDialogMessage intercepts. I have never used it personally but the docs seem to indicate that it is what you're looking for.
Posted on 2003-12-23 14:41:29 by donkey
greenant,
You should be able to make a modal box do what you want it to without resorting tricks like changing it to modeless. You don't have to add IsDialogMessage or anything else either. It is a straightforward coding technique. Check your resource statements to make sure they are in order, and the names match correctly. Make sure your control has a callback routine, and check it out with a debugger to make sure your message gets posted there when you press the key. If you can't find the problem that way, ZIP post a truncated version of your code including the resource statements. Otherwise I can send you a simple program example that contains one push button control in a modal dialog box that activates by left clicking the mouse on it, or pushing the page down key. Ratch
Posted on 2003-12-24 19:48:52 by Ratch
Please, post the sample program with the push button
Posted on 2003-12-25 07:10:03 by greenant
greenant,

Sorry for the delay. The holiday slowed me down. Selecting the help menu will cause a modal dialog box with one custom control, an oval button to be created. Clicking on the oval control with the mouse, or pushing down the space or page-down key will cause the dialog box to be deleted. Notice that the main window creates the dialog box and oval control when it receives a WM_COMMAND from the menu's help selection. The oval control captures the left mouse click and space/page-down keystrokes because it has the focus. Then it does a SendMessage to the parent dialog box. If the dialog box detects that it has received a message from the oval control, it kills itself by doing a EndDialog. The rest is history.

This program has a custom control. I can send you a program that uses only "standard" controls like radio buttons and defpushbuttons. These standard controls do not use the SendMessage API, because they are received directly via the WS_COMMAND in the dialog's callback procedure.

This program was MASMatized from a C program in Petzold's book. Ask if you have any questions. Ratch
Posted on 2003-12-25 23:56:15 by Ratch
I use only standard control & I don't subclass them to trap WM_KEYUP message.
I want to trap WM_KEYUP message from the dialog box procedure without using custom controls
Posted on 2003-12-26 10:20:24 by greenant
greenant,
OK here it is. You should be able to do what you want now. Notice that the buttons only activate when the key is let up. As before, this program came from Petzold's book. Ratch
Posted on 2003-12-27 00:25:00 by Ratch
Maybe you can't understand me.
This is my dialog box. I want that when the user press PAGE_UP and PAGE_DOWN the up-down control ID_CDTX_NUM_UD go up and down



IDD_SET_CDTEXT DIALOG DISCARDABLE 0, 0, 328, 259
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "Titoli delle tracce"
FONT 8, "MS Sans Serif"
BEGIN
GROUPBOX "Informazioni generali",IDC_STATIC,5,10,315,120
LTEXT "Categoria",IDC_STATIC,15,29,35,8
COMBOBOX IDC_CDTX_CATEGORIA,65,25,90,130,CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "Genere",IDC_STATIC,15,49,24,8
COMBOBOX IDC_CDTX_GENERE,65,45,90,130,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
LTEXT "Artista",IDC_STATIC,15,69,20,8
EDITTEXT IDC_CDTX_ARTISTA,65,65,150,14,ES_AUTOHSCROLL
PUSHBUTTON "Imposta per tutte le tracce",IDC_CDTX_SET,225,65,89,14
LTEXT "Titolo",IDC_STATIC,15,88,18,8
EDITTEXT IDC_CDTX_TITOLO,65,85,150,14,ES_AUTOHSCROLL
LTEXT "Anno",IDC_STATIC,15,107,18,8
EDITTEXT IDC_CDTX_ANNO,65,105,150,14,ES_AUTOHSCROLL | ES_NUMBER
GROUPBOX "Informazioni della traccia",IDC_STATIC,5,140,315,90
LTEXT "Traccia num.",IDC_STATIC,15,163,42,8
EDITTEXT IDC_CDTX_NUM,65,160,40,14,ES_CENTER | ES_READONLY |
ES_NUMBER
CONTROL "Spin1",IDC_CDTX_NUM_UD,"msctls_updown32",
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
UDS_ARROWKEYS | UDS_HOTTRACK,105,160,11,14
LTEXT "Titolo",IDC_STATIC,15,188,18,8
EDITTEXT IDC_CDTX_TTITOLO,65,185,195,14,ES_AUTOHSCROLL
LTEXT "Artista",IDC_STATIC,15,208,20,8
EDITTEXT IDC_CDTX_TARTISTA,65,205,195,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "&Salva",IDOK,113,238,50,14
PUSHBUTTON "&Annulla",IDCANCEL,163,238,50,14
END
Posted on 2003-12-28 04:11:35 by greenant
greenant,
Well, this has been an educational experience for me. I tried everything, and it seems like a WM_KEYDOWN message never comes from the standard UP-DOWN control defined by a resource template. It looks like if you want to get that message, you have to customize your own. If you find out how to do it easily somehow, I would appreciate it if you shared that knowledge. I was only able to get a WS_NOTIFY, WS_VSCROLL, and SB_THUMBPOSITION from it. The code I used is enclosed. Good luck. Ratch
Posted on 2003-12-29 20:15:38 by Ratch
Only a curious, what is the reason of your modal choice? Surely may a few but which is your reason?
Posted on 2003-12-31 21:45:12 by cakmak
The dialog box is modal because that is the only solution.
The user press a button or select a menu. Then the dialog box pop up and the user must fill edit boxes and press Save or Cancel.
The only way to do this is to use a modal dialog box
Posted on 2004-01-05 06:37:52 by greenant