- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an application which creates a menu-driven interface with some buttons in a dialog box at the bottom of the window. The problem I'm having is that I can't make the buttons visible when the application starts up. They are there since they can be clicked and as soon as the application is moved or a menu posted they appear. Any suggestions on how I can make the buttons visible would be greatly appreciated. I've added a solution that replicates the problem in both 64 and 32 bit versions.
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Clearly redraw messages are not being correctly processed for the buttons in the dialog concerned.
Using the Microsoft tool SPYXX.EXE, the messages sent to the child window when the main window is tweaked when the buttons are invisible after which the buttons become visible are:
<00001> 000303B6 S WM_NCPAINT hrgn:00000001
<00002> 000303B6 R WM_NCPAINT
<00003> 000303B6 S WM_ERASEBKGND hdc:23010C57
<00004> 000303B6 S .WM_CTLCOLORDLG hdcDlg:23010C57 hwndDlg:000303B6
<00005> 000303B6 R .WM_CTLCOLORDLG hBrush:01100059
<00006> 000303B6 R WM_ERASEBKGND fErased:True
<00007> 000303B6 S .WM_PAINT hdc:00000000
<00008> 000303B6 R .WM_PAINT
<00009> 000303B6 S ..WM_CTLCOLORBTN hdcButton:7E01054E hwndButton:000303B0
<00010> 000303B6 R ..WM_CTLCOLORBTN hBrush:01100059
<00011> 000303B6 S ..WM_CTLCOLORBTN hdcButton:7E01054E hwndButton:000303B2
<00012> 000303B6 R ..WM_CTLCOLORBTN hBrush:01100059
<00013> 000303B6 S .WM_NCPAINT hrgn:00000001
<00014> 000303B6 R .WM_NCPAINT
<00015> 000303B6 S .WM_ERASEBKGND hdc:7E01054E
<00016> 000303B6 S ..WM_CTLCOLORDLG hdcDlg:7E01054E hwndDlg:000303B6
<00017> 000303B6 R ..WM_CTLCOLORDLG hBrush:01100059
<00018> 000303B6 R .WM_ERASEBKGND fErased:True
<00019> 000303B6 S .WM_PAINT hdc:00000000
<00020> 000303B6 R .WM_PAINT
<00021> 000303B6 S ..WM_CTLCOLORBTN hdcButton:7E01054E hwndButton:000303B0
<00022> 000303B6 R ..WM_CTLCOLORBTN hBrush:01100059
<00023> 000303B6 S ..WM_CTLCOLORBTN hdcButton:7E01054E hwndButton:000303B2
<00024> 000303B6 R ..WM_CTLCOLORBTN hBrush:01100059
<00025> 000303B6 S .WM_NCPAINT hrgn:00000001
<00026> 000303B6 R .WM_NCPAINT
<00027> 000303B6 S .WM_ERASEBKGND hdc:23010C57
<00028> 000303B6 S ..WM_CTLCOLORDLG hdcDlg:23010C57 hwndDlg:000303B6
<00029> 000303B6 R ..WM_CTLCOLORDLG hBrush:01100059
<00030> 000303B6 R .WM_ERASEBKGND fErased:True
<00031> 000303B6 S .WM_PAINT hdc:00000000
<00032> 000303B6 R .WM_PAINT
<00033> 000303B6 S ..WM_CTLCOLORBTN hdcButton:C4010746 hwndButton:000303B0
<00034> 000303B6 R ..WM_CTLCOLORBTN hBrush:01100059
00303B6 is the handle to the dialog frame
00303B0 and 00303B2 are the handles of the two buttons that are redrawn.
Hope this helps!
P.S. you omitted RESOURE.FD from your zipped archive which caused a lot of extra work to get your code compiled..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I played around with your MainWndProc. It looked to me that some messages were not being properly passed on, so I added calls to
DefWinowProc instead of setting MainWndProc=0 or 1. The buttons now appear,although of course,there may be other effects that your stripped-down code may not show. Here are my changes:
select case(mesg)
case (WM_PAINT) ! Set to WM_SIZE to help with debugging
MainWndProc = DefWindowProc( hWnd, mesg, wParam, lParam )
return
case (WM_GETICON, WM_ACTIVATEAPP, WM_NCCREATE:WM_NCMBUTTONDBLCLK)
MainWndProc = DefWindowProc( hWnd, mesg, wParam, lParam )
return
end select
! Handle all events not processed
select case ( mesg )
case (WM_DESTROY)
call PostQuitMessage( 0 )
case (WM_CREATE)
if (exit_buttons_dlg%hWnd == 0) then
call CreateChildDialog(hwnd)
call ResizeChildDialog(hwnd)
end if
MainWndProc = DefWindowProc( hWnd, mesg, wParam, lParam )
return
! Let the default window proc handle all other messages
case default
MainWndProc = DefWindowProc( hWnd, mesg, wParam, lParam )
end select
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for this information. I've found spyxx.exe in my VS installation and used it to confirm that the buttons are not getting an initial WM_PAINT message. What I don't understand is why or how I can fix it. As far as I can see it shouldn't be necessary to send explicit WM_PAINT messages since the FEXPLORER example doesn't need to so if you've got any ideas on this I'd appreciate it.
I did not intentionally omit the resource.fd file so I've just added it - sorry about that.
Simon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have added the call you suggested and the application now works peoperly. Thank you very much for your help.
Simon

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page