Software Archive
Read-only legacy content
17061 Discussions

Redrawing a dialog window

nijhuis
Beginner
290 Views
I'm using in my CVF program a Win32-driven dialog window. This window contains some ownerdrawn buttons. These buttons are painted in a background color by the program.
A button click will activate a "choosecolor"-dialog window to select a color. After selection the button should be painted in the selected color
My problem is now that the redraw of the button is not done directly. When I do a mouseclick somewhere in the window the redraw is done. But which function should be called to redraw the buttons without mouse activation?

Guus.
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
290 Views
Try

 
iDummy = InvalidateRect(GetDlgItem(hDlg, IDC_MYBUTTON), NULL_RECTANGLE) 
iDummy = UpdateWindow(GetDlgItem(hDlg, IDC_MYBUTTON)) 


or, if it doesn't work, invalidate entire dialog (hDlg) instead of just that button.
0 Kudos
nijhuis
Beginner
290 Views
With some adaptations to the call to InvalidateRect, it works for both a single button or the whole window.
I use: iDummy = Invalidaterect(GetDlgItem(hDlg, IDC_MYBUTTON), null_rect, .true. ).
I could not find the symbol NULL_RECTANGLE, but module dfwinty contains the pointer null_rect. Though I could not find an initialization of null_rect, it works and I hope it remains working. There is further a third argument bErase for InvalidateRect which indicates wether the background should be erased or not before updating the rectangle.

I was searching for a long time for a solution, but it appears again that this forum was very helpful.
Jugoslav, thanks for the help.

Guus.
0 Kudos
Reply