Hi all !
Hutch, how are you ?
Michael, how are you ?
I need to use a window to show what a procedure is doing and i dont know how to do this.
It is like this:
1º - I want to open that window and show a message
2ª - i want to run one procedure
3º - i want to close that window.
What type of window i should use ? What the procedure to call ? It is not MessageBox. What is ?
Thank you
RuiLoureiro
Hi Rui,
I gather you want to use the Window for debugging and probably the simplest technique is to use a console window (even if the app is normal gui) and display whever info you need there. when you are finished, remove the console display code and build it as a normal GUI app.
.586
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
;***************************************************************************************************
openDbgWin proto
closeDbgWin proto
showDbgMsg proto pMsg:DWORD,lenMsg:DWORD
;***************************************************************************************************
.data
aMessage db "Hello! I'm a debug message :)",13,10
.data?
hStdOut HANDLE ?
.code
start:
invoke openDbgWin
invoke showDbgMsg, ADDR aMessage,SIZEOF aMessage
;;pause.. so we can see it -- only for testing ;)
invoke Sleep, 3000
invoke closeDbgWin
invoke ExitProcess, NULL
;***************************************************************************************************
openDbgWin proc
invoke AllocConsole
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov hStdOut,eax
ret
openDbgWin endp
closeDbgWin proc
invoke FreeConsole
ret
closeDbgWin endp
showDbgMsg proc pMsg:DWORD,lenMsg:DWORD
LOCAL chWritten:DWORD
invoke WriteConsole, hStdOut,pMsg,lenMsg,ADDR chWritten,NULL
ret
showDbgMsg endp
;***************************************************************************************************
end start
Just copy the procs into your code, and use like in the example :wink
(Don't forget to add newlines to the end of your messages - "13,10")
Hi Hutch, many thanks to you
Now i developed a program ( a big program supported by 2 Libs! It runs ) in GUI for wINDOWS xp, so it´s not a console app. I want a to open a window like MessageBox, but not with buttons.
Tedd, many thanks, but i think your code is for a console app. and it not run in GUI for Windows XP. I want to use the window style like MessageBox
Thanks.
RuiLoureiro
Hello Rui, you can open a console prompt from a GUI app, see AllocConsole at:
http://www.masm32.com/board/index.php?topic=8126.0
Hi Mark
Yes, it can work but this is not the style of window i want to use, i'm afraid. There is not another way to do what i want ?
Thank you
No, it is for a windows app - it just uses a console for the messages.
I just left out all of the window code so it would be easy to understand.
Try it first, only then complain ::)
If you need a debug window that doesn't look like a console, but more like notepad, then you'll have to create a specific window/dialog with an edit-control child, and then append text into that -- it's quite a bit more work.
Quote from: Tedd on November 16, 2007, 06:49:52 PM
If you need a debug window that doesn't look like a console, but more like notepad, then you'll have to create a specific window/dialog with an edit-control child, and then append text into that -- it's quite a bit more work.
Yes, Tedd, i think that is what i am looking for: a window that looks like a MesageBox or Dialog boxes. I have to study how to create a dialog window with an edit-control child as you say. I think it is what i am looking for.
Many Thanks for your help, Tedd
RuiLoureiro
Hi Rui, in that case then look through the examples and tutorials that come with MASM32, there should be a few examples of child windows. :U
Hi Rui,
Try also Vkim's debugging tool :
http://www.masm32.com/board/index.php?topic=8126.msg59353#msg59353
Hi Rui,
The attachment is my attempt at a simple debug (dialog) window that uses a list box to display strings.
[attachment deleted by admin]
Also, another new debugging tool is this: "Useful little debugging tool "peek.dll" (http://www.masm32.com/board/index.php?topic=8135.0)
Hi Mark, Vortex
Hi MichaelW, how are you ?
Hi all.
Thank you for your helps. I couldnt reply till now cause a domestic accindent of my wife.
I dont want a window to debug but to send a message to say what the computer is doing like savingi databases. This is the idea. To debug my procedures i use a set of procedures to show data and registers and MessageBoxes to stop the program with «Step 1, step 2, etc. » and so i follow the program. This is the method i use to debug my programs.
Now i am studyng how to use an edit box and how to append a string into it to do the window
Thank you
RuiLoureiro
MichaelW, I read ( in seconds ) your dbgwin.asm and i saw that with ModlessDialogBoxes ( i never used ) i can make the window i am looking for. Go to see
Rui,
If I understand ypou properly you want a window to display some data when you need it as part of our application. This is just a simple CreateWindowEx() type of window wiht whatever style you like where you use the original windoew as a parent window to the one you wish to display data with.
Hutch,
I think you understood. But i have problems with styles. What´s the style for a window without buttons ?
I tried this 2 types:
.data
; _hInstance and _hWndCur is from the main program.
_EDIT_Class   db "None", 0  ;
;_EDIT_Class   db "EDIT",0        ; name of window class
_EDIT_Name   db "A executar", 0   ; the name is the message for an edit box !
_EDIT_hWnd   dd 0             ; handle
.code
; ««««««««««««««««««««««««««««««««««««
SendExecMsg     proc         ; to open the window
          pushfd
          pushad
          ;
         Â
invoke CreateWindowEx, 1h, offset _EDIT_Class, offset _EDIT_Name, 54000000h, \
             260, 100, 280, 80,\                           ; X,Y + Width, Height pixel
             _hWndCur, 0h, _hInstance, 0
          ;
          mov   _EDIT_hWnd, eax
          ;
          popad
          popfd
          ret
SendExecMsg     endp
; ««««««««««««««««««««««««««««««««««««««««««««««
CloseExecMsg    proc          ; to close the window
          pushfd
          pushad
          ;
          invoke  DestroyWindow, _EDIT_hWnd
          ;
          popad
          popfd
          ret
CloseExecMsg    endp
When i use it with «_EDIT_Class   db "EDIT",0» it works but with None doesnt work
What i know ?
;------------------------------------------------------------------------------
; This is an example from Test Department (EDIT box)
;------------------------------------------------------------------------------
;push  0h             ;lpParam, extra pointer data 0=no data
;push  _hInstance         ;hInstance, handle of our program
;push  910h            ;hMenu, the child-window ID
;push  _hWnd            ;hWndParent, handle parent window 0=no
;push  18h             ;intnHeight, window height pixel
;push  80h             ;intnWidth, window width pixel
;push  60h             ;inty, vertical position window
;push  1B0h            ;intx, horizontal position window
;push  54000000h          ;dwStyle, static window style
                   ;WS_CHILD      = 40000000h
                   ;WS_VISIBLE     = 10000000h
                   ;WS_CLIBSIBLINGS  = 4000000h
                   ;WS_TABSTOP     =  10000h
                   ;          = 54010000h
;push  0h             ;lpWindowName, pointer to window name
;push  OFFSET _EDIT_Class     ;lpClassName, pointer to class name
;push  1h             ;dwExStyle,look WIN32.HLP + windows.inc
;call  CreateWindowExA       ;- API Function -
;mov   _EDIT1_hWnd, eax      ;hwnd, return value=handle of window
Why the window doesnt open ? Do i need to use RegisterClassEx ?
Thank you for some help.
RuiLoureiro
Rui,
Unless you are using a predefined class like a control, you must create a class for your own window using the WNDCLASSEX structure and RegisterClassEx().
Create the windows with the "WS_POPUP or WS_CAPTION" styles for a windows with a titlebar and no buttons.
Quote from: hutch-- on November 19, 2007, 06:50:06 PM
Unless you are using a predefined class like a control, you must create a class for your own window using the WNDCLASSEX structure and RegisterClassEx().
Create the windows with the "WS_POPUP or WS_CAPTION" styles for a windows with a titlebar and no buttons.
Very Good !!!
Hutch, thanky so much ! I am going to work. Have a nice day or night !
RuiLoureiro
Hutch, what's wrong ? The window doesnt open or is closed before CloseExecMsg be called.
When i call SendExecMsg, the window doesnt appear.
.data
; Child Window
;
_ClassChild   db "WinChild", 0        ; class name
_NameChild    db "A executar ...", 0   ; title name
_hWndChild    dd 0              ; handle
;»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
.data?
align 4
_wcChild    WNDCLASSEX <?>
;»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
.code
WinMain   proc hInst:DWORD, hPrevInst:DWORD, CmdLine:LPSTR, CmdShow:DWORD
       ;.................................................................
      ;
      ; Preencher a estrutura WNDCLASSEX para a janela CHILD
      ; ----------------------------------------------------
      mov  _wcChild.cbSize,   SIZEOF WNDCLASSEX
      mov  _wcChild.style,    WS_OVERLAPPED or WS_BORDER or WS_CHILD or   WS_POPUP  or  WS_CAPTION
       mov  _wcChild.lpfnWndProc, 0
       mov  _wcChild.cbClsExtra, NULL
       mov  _wcChild.cbWndExtra, NULL
       push _hInstance
       pop  _wcChild.hInstance
       mov  _wcChild.hbrBackground, COLOR_BACKGROUND+1  ; COLOR_WINDOW+1   Â
       mov  _wcChild.lpszMenuName, 0                ; menu name in resource file
       mov  _wcChild.lpszClassName, offset _ClassChild      ; name of windows class
      ;
      ; Registar a classe WNDCLASSEX da janela Child
      ; --------------------------------------------------------------
      invoke RegisterClassEx, addr _wcChild              ; new
;.........................................
    ............................
    ............................
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««
SendExecMsg     proc Â
          pushfd
          pushad
          ;
invoke CreateWindowEx, 300h, offset _ClassChild, offset _NameChild,\
             WS_BORDER or WS_CHILD or WS_POPUP or WS_CAPTION, \
             260, 100, 280, 80,\         ; X,Y + Width, Height pixel
             _hWndCur, 0h, _hInstance, 0
          ;
          mov   _hWndChild, eax
          ;
          ;invoke ShowWindow, _hWndChild, SW_SHOWNORMAL
          ;
          popad
          popfd
          ret
SendExecMsg     endp
; ««««««««««««««««««««««««««««««««««««««««««««
CloseExecMsg    proc
          pushfd
          pushad
          ;
          invoke  DestroyWindow, _hWndChild
          ;
          popad
          popfd
          ret
CloseExecMsg    endp
;*******************************************************
New: CreateWindowEx returns 0 . Why ? Need a processor ?
;*******************************************************
Rui,
Here is a simple example of how to create a child window of the type you require. Look at the childwin code at the end of the source code.
[attachment deleted by admin]
Hutch,
Thank you for the example. I dont know where was the problem but now it works. I have my Child window.
The problem, now is that i print the message, but the system erase the client area and we dont see the message.
Here is my last version. I think you understand in a few seconds what im doing.
Another problem is with the background color of the text (new: it is solved )
;.................................................................
Amarelo equ 00FFFFh
;.....................................
.data
_pMsgToSend   dd 0
_hWndChild dd 0
.data?
_WidthChr dd ?
dd ?
_wcChild    WNDCLASSEX <?>
.code
;..................................................
WinMain   proc hInst:DWORD, hPrevInst:DWORD, CmdLine:LPSTR, CmdShow:DWORD
      ;.................................................................
      ;
      ; Preencher a estrutura WNDCLASSEX para a janela CHILD
      ; ----------------------------------------------------
   mov  _wcChild.cbSize,   SIZEOF WNDCLASSEX
           mov  _wcChild.style,    CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW
     mov  _wcChild.lpfnWndProc, offset WndProcB
       mov  _wcChild.cbClsExtra, NULL
   mov  _wcChild.cbWndExtra, NULL
   push _hInstance
   pop  _wcChild.hInstance
       mov  _wcChild.hbrBackground, COLOR_BACKGROUND+1 ; COLOR_WINDOW+1   Â
   mov  _wcChild.lpszMenuName, 0           ; menu name in resource file
   mov  _wcChild.lpszClassName, offset _ClassChild  ; name of windows class
      ; --------------------------------------------
      ; Registar a classe WNDCLASSEX da janela Child
      ; --------------------------------------------
      invoke RegisterClassEx, addr _wcChild
;....................................
;Â Â Â other
;--------------------------------------------------------------------
; ««««««« for CHILD WINDOW «««««««««««««««««««««««««««««««««««««
WndProcB    proc  hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
           pushad                Â
           ;
           mov   eax, uMsg
           cmp   eax, WM_PAINT
           jne   _eWndProcB
           ;
           ; imprime a mensagem
           ; ----------------------------
           call    PrPasMsg     Â
           ;
_eWndProcB:Â popad
           ;
           invoke DefWindowProc, hWnd, uMsg, wParam, lParam
           ret
WndProcBÂ Â Â Â endp
;»»»»» In the file saved to a LIB i have »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
SendExecMsg     proc  NMsg:DWORD Â
              pushfd
              pushad
              ;
              cmp   _hWndChild, 0
              jne   _eSendExecMsg
         Â
              invoke CreateWindowEx, WS_EX_LEFT,
                  offset _ClassChild, offset _NameChild,
                  WS_POPUP or WS_CAPTION,
                  260, 380, 280, 80,                 ; X,Y + Wid,Hei pixel
                  _hWndCur, 0h, _hInstance, 0
              ;
              mov   _hWndChild, eax
              ;
              invoke ShowWindow, _hWndChild, SW_SHOW    Â
;...........................................................................
          ;
          ; Get Message from the table
          ; --------------------------------------
              mov   esi, offset _TblExecMsg       ; message table
              mov   ebx, NMsg
              cmp   ebx, 0
              je   _eSendExecMsg
              ;
              cmp   ebx, dword ptr [esi - 4]      ; number of messages
              ja   _eSendExecMsg
              ;
              dec   ebx
              shl    ebx, 2
              mov   eax, dword ptr [esi + ebx]    ; eax =message pointer
              mov   _pMsgToSend, eax
              ;
              call    PrPasMsg
              ;
_eSendExecMsg:Â Â Â popad
              popfd
              ret
SendExecMsg     endp
; ----------------------------------------------------------------------------------------------
PrPasMsg    procÂ
          pushad Â
           ;
           invoke HideCaret, _hWndChild        ; never show caret
       Â
           invoke GetDC, _hWndChild
           mov   _hdcChild, eax
          ;
          ; calcula comprimento da string
          ; ----------------------------------------
          mov   ebx, _pMsgToSend
          movzx  ecx, byte ptr [ebx - 1]         Â
          invoke  GetTextExtentPoint32, _hdcChild, ebx, ecx, addr _WidthChr
          ;
          mov   edx, 280
          sub    edx, _WidthChr
          shr    edx, 1
          mov   _WidthChr, edx
          ;
          ; Cor Foreground
          ; ---------------------
          invoke  SetTextColor, _hdcChild, Amarelo
          ;
          ; Cor Background
          ; ---------------------
          invoke GetSysColor, COLOR_BACKGROUND ; window background color
          invoke  SetBkColor, _hdcChild, eax          Â
          ;
           ; Print Test
           ; -------------
           mov   ebx, _pMsgToSendÂ
           movzx  ecx, byte ptr [ebx - 1]
           invoke  TextOut, _hdcChild, _WidthChr, 20, ebx , ecx       Â
           invoke ReleaseDC, _hWndChild, _hdcChild
           ;
           popad
           ret
PrPasMsg    endp
; ««««««««««««««««««««««««««««««««««««««««««««««««««
CloseExecMsg    proc
              pushfd
              pushad
              ;
             cmp   _hWndChild, 0
              je   _eCloseExecMsg         ; is closed -> exit !
         Â
              invoke  DestroyWindow, _hWndChild
              ;
              mov   _hWndChild, 0          Â
              ;
_eCloseExecMsg:Â Â popad
              popfd
              ret
CloseExecMsg    endp
;.................. END
NEW: the first time i call SendExecMsg, it doesnt show the message. The second and so forth it shows
     How to give the text the same background color as the background of the window ? Can you help me ? (NEW: now, it works. Thank you Hutch)
Rui,
If you want to draw the text on the child window yourself you must do it from the WM_PAINT message for the child window so that it will remain visible when other windows have overlapped it. In most instances it would be easier for you to use a control like a text edit control or a static control as either will handle large amounts of text without display problems.
The basic code you are using does not appear to have been written by someone who properly understands how a window and its messaging works. I would ensure that all messages processed are done according to the documentation in either the old winhelp file win32.hlp or the later MSDN/SDK style help.
Quote from: hutch-- on November 20, 2007, 09:16:15 PM
... you must do it from the WM_PAINT message for the child window so that it will remain visible when other windows have overlapped it. In most instances it would be easier for you to use a control like a text edit control or a static control as either will handle large amounts of text without display problems.
Hutch,
Thanks for the reply.
I have not problems with documentation. I corrected the last version. As you know, it is my first window program. And, many times (!) I forget some details (like many people). And there are details i dont know and i ask for help. Isnt it correct ?
In this case (printing a msg), i am seeing that it is easier to use a text edit control.
Thank you, Hutch (and all that want to help me )
Rui Loureiro
Hi Rui, consider going through the Iczelion tutorials at:
http://win32assembly.online.fr/tutorials.html
This should give you many ideas for your program. :U
Rui,
This example is an attempt to answer your recent questions.
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  .data
    hInst   dd     0
    hWnd   dd     0
    fTextOut dd     not 0
    fWhite  dd     not 0
    wcx    WNDCLASSEX <>
    msg    MSG     <>
    className db "test_window_class", 0
    txt    db 13,10
         db "Press F1 to toggle this text between "
         db "on and off.",13,10,13,10
         db "Press F2 to toggle the window background "
         db "color between white and light gray.", 13,10,13,10
         db "Press Escape to close this window.", 0
  .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
WndProc proc hwnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
  LOCAL ps:PAINTSTRUCT
  LOCAL rc:RECT
  LOCAL hdc:HDC
  SWITCH uMsg
   CASE WM_CREATE
   CASE WM_KEYDOWN
    SWITCH wParam
     CASE VK_ESCAPE
      invoke PostQuitMessage, NULL
     CASE VK_F1
      ; --------------------------------------------------------
      ; Invalidating the client area causes it to be repainted.
      ; --------------------------------------------------------
      not fTextOut
      invoke GetClientRect, hwnd, ADDR rc
      invoke InvalidateRect, hwnd, ADDR rc, TRUE
     CASE VK_F2
      .IF fWhite
       invoke GetStockObject, LTGRAY_BRUSH
      .ELSE
       invoke GetStockObject, WHITE_BRUSH
      .ENDIF
      not fWhite
      invoke SetClassLong, hwnd, GCL_HBRBACKGROUND, eax
      invoke GetClientRect, hwnd, ADDR rc
      invoke InvalidateRect, hwnd, ADDR rc, TRUE
    ENDSW
   CASE WM_PAINT
    ; --------------------------------------------------
    ; For the text to persist it must be redrawn each
    ; time the client area of the window is repainted.
    ; --------------------------------------------------
    invoke BeginPaint,hwnd,ADDR ps
    .IF fTextOut
     ; ------------------------------------------------------
     ; Setting the background mix mode to TRANSPARENT causes
     ; DrawText to write the foreground pixels and leave the
     ; background pixels untouched.
     ; ------------------------------------------------------
     invoke SetBkMode, ps.hdc, TRANSPARENT
     invoke GetClientRect, hwnd, ADDR rc
     invoke szLen, ADDR txt
     mov ecx, eax
     invoke DrawText, ps.hdc, ADDR txt, ecx, ADDR rc,
              DT_WORDBREAK
    .ENDIF
    invoke EndPaint,hwnd,ADDR ps
   CASE WM_CLOSE
    ;invoke PostQuitMessage,NULL  ; ERROR IN ORIGINAL POSTING
    invoke DestroyWindow, hwnd
   CASE WM_DESTROY
    invoke PostQuitMessage,NULL
   DEFAULT
    invoke DefWindowProc, hwnd, uMsg, wParam, lParam
    ret
  ENDSW
  return 0
  ret
WndProc endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  invoke GetModuleHandle, NULL
  mov hInst, eax
  mov wcx.cbSize,    sizeof WNDCLASSEX
  mov wcx.style,     CS_HREDRAW or CS_VREDRAW \
              or CS_BYTEALIGNWINDOW
  mov wcx.lpfnWndProc,  OFFSET WndProc
  mov wcx.cbClsExtra,  NULL
  mov wcx.cbWndExtra,  NULL
  m2m wcx.hInstance,   hInst
  invoke GetStockObject, WHITE_BRUSH
  mov wcx.hbrBackground, eax
  mov wcx.lpszMenuName, NULL
  mov wcx.lpszClassName, OFFSET className
  invoke LoadIcon, NULL, IDI_APPLICATION
  mov wcx.hIcon,     eax
  invoke LoadCursor, NULL, IDC_ARROW
  mov wcx.hCursor,    eax
  mov wcx.hIconSm,    0
  invoke RegisterClassEx,ADDR wcx
  ; -------------------------------------------------------------
  ; The WS_POPUP style will produce a fixed-size window with no
  ; title bar. The WS_BORDER style can be combined with WS_POPUP
  ; to create a wider border. The WS_CAPTION style will add a
  ; title bar with no buttons, and increase the width of the
  ; border. Using the WS_OVERLAPPEDWINDOW style instead will
  ; produce a normal application window.
  ; -------------------------------------------------------------
  invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,
             ADDR className,
             chr$("Test"),
             WS_POPUP or WS_CAPTION,
             0,0,400,300,
             NULL,NULL,
             hInst,NULL
  mov hWnd, eax
  invoke ShowWindow, hWnd, SW_SHOWNORMAL
  invoke UpdateWindow, hWnd
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
 msgLoop:
  invoke GetMessage, ADDR msg, NULL, 0, 0
  .IF (eax != 0)
    invoke TranslateMessage, ADDR msg
    invoke DispatchMessage, ADDR msg
    jmp msgLoop
  .ENDIF
  exit msg.wParam
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
If you were doing this as an exercise almost anything would be reasonable. But if your goal is to create a window that can display debug messages, then displaying the messages directly on the client area of the window is doing it the hard way. Using an appropriate control to display the messages would be much easier. In my previous example I used a list box because I felt it was the best choice for displaying short messages. Another possibility for displaying longer messages would be an edit control. And another possibility would be a static text control, but for displaying multiple messages it has the drawback of not being user scrollable.
Hi MichaelW,
Isnt there another direct method to clear the screen ? InvalidateRect doesnt send WM_PAINT immediatly.
Thank you
Rui
InvalidateRect.. then UpdateWindow..
But do you really need to update immediately?
Tedd,
I think i need, but i need to see how it works in my program.
Quote from: Tedd on November 27, 2007, 01:23:20 PM
But do you really need to update immediately?
Hi
      At some point of my prog i have one screen drawn. And then i press a key and i want to draw another screen before openning a commom control dialog box to get some data.
      To draw the new screen i need to clear the screen (client area).
      It is something like this:
1º - i have screen drawn
2ª - press a key
3ª - clear the screen and draw another ( this proc is under WM_PAINT too )
4ª - open a commom control dialog box and wait for data
5ª - Return to DefWindowProc
     How to clean the screen ?
Rui
InvalidateRect will cause the contents of your window to be repainted - that means you will get a WM_PAINT message, with the whole client area to be redrawn. Just redraw the contents of your window according to the state changed by the keypresses. The dialog can be created on the keypress (after invalidate) - it's a separate window, so it shouldn't stop the main window from being redrawn.
Quote from: Tedd on December 10, 2007, 01:00:53 PM
The dialog can be created on the keypress (after invalidate) - it's a separate window, so it shouldn't stop the main window from being redrawn.
Hi Tedd,
       I am learning this little questions of windows. Thank you so much
Rui
How to change the window background color after creating a window ? I didnt find out yet.
InvalidateRect - UpdateWindow doesnt work. It doesnt clean the previous screen.
Rui
Rui,
Its done by changing the background brush in the window class.
invoke SetClassLong, [hwnd], GCL_HBRBACKGROUND, [hNewBrush]
// If the class is using a brush you created use DeleteObject here to destroy the returned hBrush
invoke InvalidateRect, NULL, TRUE
You can set the 'default' background colour by setting a colour value as the background brush for your window - in the window-class structure, given to registerclass (e.g. "00000ffh" instead of "COLOR_WINDOW+1")
To dynamically change it, you can either modify the class brush (donkey's method) if you don't need to change often, or simply use FillRect (or Rectangle) if you need to change the colour many times.
Hutch, Donkey and Tedd,
                  Thank you !
I used IvalidateRect, hWnd, NULL, TRUE ... and doenst work ... yet.
I have only one main window, style CS_OWNDC;
The client area is divided in 3 areas: header, workspace and bottom;
I have  Table1: values and pointers   ( set 1 )
       Table2: values and pointers  ( set 2 )
       pActiveTable = offset Table1 (points to Table1 at the beginning )
The proc under WM_PAINT uses pActiveTable to print data on the screen;
Pressing one given key pActiveTable = offset Tabel2
and before calling the commom control dialog box i put
           IvalidateRect, hWnd, NULL, TRUE
           UpdateWindow, hWnd
What happens ? When i press the key the header and bottom change but the previous workspace content stay on the screen when the dialog box opens. It doenst print anything on the worksapce because it should not print anything and it is correct.
In the menu i have a proc that shows all values and pointers in the ActiveTable and all things are correct.
Is there any reason to not clean the screen ? How to clean it ?
note: dont worry, it's a high tech proggy !
Rui
Hi all
The problem is solved.
Thanks