News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Window help

Started by RuiLoureiro, November 16, 2007, 12:38:51 PM

Previous topic - Next topic

RuiLoureiro

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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Tedd

.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")
No snowflake in an avalanche feels responsible.

RuiLoureiro

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

Mark Jones

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
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

RuiLoureiro

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

Tedd

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.
No snowflake in an avalanche feels responsible.

RuiLoureiro

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

Mark Jones

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
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08


MichaelW

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]
eschew obfuscation

Mark Jones

"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

RuiLoureiro

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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

RuiLoureiro

#14
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