Making dialog buttons visible

Making dialog buttons visible

sgeard@cad-schroer.co.uk的头像

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

附件尺寸
下载 tt.zip13.43 KB
5 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Anthony Richards的头像

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..

Anthony Richards的头像

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

sgeard@cad-schroer.co.uk的头像

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

sgeard@cad-schroer.co.uk的头像

I have added the call you suggested and the application now works peoperly. Thank you very much for your help.

Simon

登陆并发表评论。