News:

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

PopUp Window

Started by RuiLoureiro, August 27, 2008, 09:10:52 PM

Previous topic - Next topic

Mark Jones

Hello Rui, glad to see you are still programming in assembler. :U

If you have never tried OllyDbg, please give it a try. It is very helpful for finding bugs.

Using OllyDbg is very easy.
1. Download v1.10 from http://www.ollydbg.de/odbg110.zip and install it.
2. Next, open it and press F3 to load your executable file. At this point probably very few windows will be visible, so you might want to open addititional ones from the Window menu.
3. The highlighted line should be the entrypoint of your file. Press F8 repeatedly to watch as code is executed.
4. Set a breakpoint on a line by highlighting the desired line and pressing F2. Part of the line turns red to indicate it is a breakpoint. Now you can press F9 to run the code, and it will stop when execution reaches the breakpoint.
5. If an exception error occurs, the bottom statusbar displays which error occured and at what address. In some rare cases, it is possible to continue debugging by pressing shift+F7/F8/F9.
6. To restart debugging the application, press Control-F2.

That's it. There is much more OllyDbg is capable of, but these simple steps are really eye-opening. It really helps to understand how things are working.

Good luck, and have fun! :bg
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

RuiLoureiro

BlackVortex,
                 About this you wrote to jj2007

«@ jj2007
Well, you could probably use an empty file with the correct name

i think you could probably give a job to jj2007: you order and he works to you.
And set the new rules of the forum.

To me, when someboby wants to help, see something that looks like incorrect
or have reasons to say something about it and "kick to corner" saying go and read etc. etc.
hummmmm its not a help, its another thing ! Why ? Simple because he have the source and he
can point the case, he can say exactly what is the problem he wants to point out.

About a question that somebody posts elsewhere (he doesnt give the source), Paul wrote:
«That is like saying, "Do you see that crowd of people over there?
One of them just robbed me, please arrest that person."»

About this you wrote
«I'm sure you will want to write your proggy from start !».

i think you didnt read all stuff from start and you dont know that i never
begin from start. Sure. Why to suppose ?

About this: «There are sources and examples for all those tutorials of course»

iam not sure that you know that there are many people in this world. Tonnes of them,
like tonnes of examples, like tonnes of tutorials, and so on. Why do you want to do
one more ? Your own case ?

Hello Mark,
            glad to see you also !  :U
            yes, still programming in assembler (for windows) and learning.

            As you say debugger «really helps to understand how things are working»
            I used it so many years in TASM for DOS, but now i use another method
            for finding bugs.
           
            But i go to try OllyDbg to learn.
           
            Thank yoy Mark
Rui

BlackVortex

@ Rui
I think you misunderstood my intentions, probably because english isn't your main language. I just downloaded your source to try to see if I could help, but it is so chaotic and difficult to read that I got disappointed. Just wanted you to reconsider remaking your program from start (based on the perfect examples) to make it truly better and not just fix one little problem and then stumble to the next etc.

And my suggestion to jj wasn't an "order" of course, I just thought that he should try using an empty .wav file to allow the source to assemble, since he said he couldn't do that and was asking you for the file.

EDIT: And why are you quoting me and underlining simple words with no special meaning ?    :'(

RuiLoureiro

BlackVortex,
             
             1st: Perhaps i misunderstood your intentions
                  ( english isn't my main language ). I suppose its yours, no ?

             2nd: About your suggestion to jj, i think there is no need to remember
                  that he could compile .wav file simple putting // to remove
                  the statement. It is not to one that understand windows programming.
                  To remove in the .asm file we use ; as we know.
                  Correct suggestion: put // ... in rsrc.rc file (my opinion).

             3rd: «...but it is so chaotic and difficult to read that I got disappointed»
                  Here i am we you. I give you a credit. Its normal. It happens with me
                  too although each one reacts as each one. But its normal. I dont like
                  to see many code files i see but ... doesnt matter and i read and
                  in many cases i understand.

             4th: About your EDIT question, i suppose you are referring "correct name"
                  What is "correct name" ? I dont know ! I didnt understand. May be
                  for this reason.

             5th: Sorry if i misunderstood your intentions. But think about this:
                  i post a lot of words asking for help. I got a reply something
                  like this: put your source code. Now, i put the source code
                  and i get a reply: go to see ... in the "next corner".             
Rui

BlackVortex

 >>          2nd: About your suggestion to jj, i think there is no need to remember
>>                 that he could compile .wav file simple putting // to remove
>>                 the statement. It is not to one that understand windows programming.
>>                 To remove in the .asm file we use ; as we know.
>>                 Correct suggestion: put // ... in rsrc.rc file (my opinion).

But aren't there references to that file ? And doesn't the proggy try to play the .wav ? Just commenting it out in the resource file isn't enough. Better to just use an empty .wav or just some random .wav file    :lol

Oh, and when I say "correct name" I just mean the exact name that's needed for the compilation.

jj2007

Quote from: BlackVortex on August 30, 2008, 06:44:35 PM
Better to just use an empty .wav or just some random .wav file

I could have tried to use an empty file, but

1st there is always a chance that code crashes in mysterious ways because it does not find the expected files

2nd (and Rui seems to agree) one can increase chances to get qualified help by simply including all necessary files, instead of letting others dig deeply in various rc and inc files. On the other hand, if I get a zip with a dozen project files, I give up immediately. I like to have everything in a single file, so that I can find the error in one instance of the editor. Same as your frustration when seeing non-conventional messaging loops etc ;-)

But really, this should not turn into an ideological debate. Rui has a little problem, and he needs help to find it. Giving him Olly was a big step.

RuiLoureiro

«Just commenting it out in the resource file isn't enough.»

Why not ? Thats the way to do this;
// TDWave7      WAVE   sound7.wav   

The reference is this in .asm file but it is a string
_WaveName7      db 'TDWave7', 0

and this
invoke  PlaySound, addr _WaveName7, _hInstance, 40005h

so PlaySound doesnt find TDWave7 and doesnt play.
But you can comment both too.
Rui

PBrennick

Good Grief,  I just read all that, will someone just phukking shoot me!

I cannot figure out if we are arguing about the problem or arguing about arguing about the problem.
-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

MichaelW

Or maybe even arguing 3 about the problem ::)

The missing wav file is a small problem that is easy to identify and rectify, IMO not worthy of even a comment, much less an extended discussion. Some of Rui's source files have been a little difficult to read, but the only problem I can see with child10.asm is that it contains a mixture of tabs and spaces in a few places.
eschew obfuscation

RuiLoureiro

Well i am sorry

      Hello Paul ! Thank you. ( I know you from my first post in this forum, Paul )
      I am glad to see you here. I appreciate your particular "style"
      (like i appreciate some others, too). I like you  :U

      Paul, Lord Byron should say "the best way to give a perfect example is putting
            someone to look for a perfect example".
     
      what to say to you, MichealW if everyboby knows you. Ever correct, Ever
      trying to help, ever with the best you can. With perfect examples
      What to say ?
      This  :green2
     
      Now, goto the Next step
     
      How could i know what the problem that someone is seeing if he dont want to say
      what the problem is ? What ? Where ?

      To write, to Assemble & Link etc. i use Quick Editor. And i use tabs and spaces
      in many places. And ;;;. I dont know what happen when we use another editor. No one
      wants to say anything. I dont guess. If it appears to be "chaotic" i dont know,
      i cannot guess.
     
      Now comes the problem i have
........................................................
Meanwhile i found this example about message processing loops

WndProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
    LOCAL var    :DWORD
    LOCAL caW    :DWORD
    LOCAL caH    :DWORD
    LOCAL Rct    :RECT
    LOCAL buffer1[260]:BYTE  ; these are two spare buffers
    LOCAL buffer2[260]:BYTE  ; for text manipulation etc..

    Switch uMsg
      Case WM_CREATE
        mov butn1, rv(PushButton,"Show",hWin,20,20,100,25,500)
        mov butn2, rv(PushButton,"Hide",hWin,20,50,100,25,510)
        mov hChild, 0

      Case WM_COMMAND
        switch wParam
          case 500
            .if hChild == 0
              mov hChild, rv(childwin,hWin)
            .endif
          case 510
            .if hChild != 0
              invoke DestroyWindow, hChild
              mov hChild, 0
            .endif

        endsw

      Case WM_SYSCOLORCHANGE
      Case WM_SIZE
      Case WM_CLOSE

      Case WM_DESTROY
        invoke PostQuitMessage,NULL
        return 0
    Endsw

    invoke DefWindowProc,hWin,uMsg,wParam,lParam   
    ret
WndProc endp

childproc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
    Switch uMsg
      Case WM_COMMAND
      Case WM_CREATE
      Case WM_SYSCOLORCHANGE
      Case WM_SIZE
      Case WM_CLOSE
    Endsw

    invoke DefWindowProc,hWin,uMsg,wParam,lParam
    ret
childproc endp

Rui

RuiLoureiro

Hi
   
The 1st problem i posted was just about how to create a popup window with
WS_SYSMENU style (SYSMENU = close button - to me its not easy to follow
SYS != CLOSE, MENU != CLOSE).
But i did an error when i used copy-paste elsewhere
(copy a proc from a file paste into PopUp5).
And i got the error.
But the next problem was: How to create it in a fixed position in such a way
that we cannot move it ? THIS IS THE main PROBLEM. I read documentation and
i didnt see any way to do it.

And Hutch answer this:
«Rui,
If you want another window attached in an imovable way to a main window,
you normally set the CHILD style for it using the main window as it parent

Its clear: i need to change to WS_CHILD style.

I did the Child6 file, but it had the same error as PopUp5.
I posted child10 ( i didnt remove «include peek.inc & @peek» from child10.asm
                   please remove it if you want to assemble)

Hutch,
      What to do to create the child window in a fixed position ?
      Do i need to add a style ? Can you tell me, please ?

      Anyone know ? Could you help me ?
      Thank you     
Rui

jj2007

Quote from: RuiLoureiro on August 31, 2008, 03:39:57 PM
      What to do to create the child window in a fixed position ?
You might not give it a caption. Or you intercept its WM_MOVE and WM_SIZE messages. Googling for subclass wm_move might help.

MichaelW

I'm still not sure that I understand what the goal is here, or how these "popup" windows will actually be used. For the code in the attachment I took a different approach that what I did in my first few attempts. Instead trying to use an application window or a dialog for the child windows, I created my own each with a static text control and a button, with all of the child windows sharing a window procedure separate from the main window procedure. The code is rough, and probably contains some substantial errors.

[attachment deleted by admin]
eschew obfuscation

RuiLoureiro

MichaelW,
            It is to learn and it is to be used.

            I liked the example. In your approach we can open 3 different popup windows.
            I want only one. And i need 1 procedure to Open and 1 procedure to Close.
            Open means: create, show and show the message number 134 (for example).
            The Open procedure is to be used in many places. So, the easiest way to
            call it is this: invoke OpenPopUp, 134 (for me). This is what i want to do.
            In the file i posted, i used Open PopUp 1, Open PopUp 2, Open PopUp 3 but
            it means send message 1, send message 2, etc. The parameters X, Y, W, H
            where i want to show the window are constants. It is to be opened in only
            one place.

            In any case your example is good. It shows another way to create it
            from a static text control with/without a button. They are in a fixed
            position and we cannot move it with the mouse. The problem is the title bar.
            I want to put a title.

            As jj say, it seems i need to intercept messages. Why intercept ?

            Many thanks to you           

jj2007,
       Thank you for your reply
       
   «You might not give it a caption.»

       The problem seems to be that: i want a title.

       Intercept ? I am not understanding, sorry. Dont Know (!?)
       
       I registered the class "WinChild". It is not a system class.
       To process the messages i registered WndProcW procedure. So i can process
       the WM_MOVE and WM_SIZE messages in WndProcW. The problem is: how ?
       If i dont pass this messages to DefWindowProc, the window moves ( when we put
       the mouse on the title bar and ...).

       Thank you

one note: this is the warning i got when i downloaded that .wav file
           «do not post on web site for download». As i dont like to break
            the rules ... But i can post the link if necessary. No problems, jj


Rui

jj2007

Quote from: RuiLoureiro on September 01, 2008, 04:11:23 PM
       Intercept ? I am not understanding, sorry. Dont Know (!?)

When your child window receives a WM_MOVE or WM_SIZE message, you can tell Windows to simply ignore it:

CASE WM_SIZE
   return 0

I hope this is correct, as I have no time to test it right now. You may have to subclass if the main message loop does not receive the child's message.
Here is a skeleton

; CASE WM_CREATE ; place this part in your WndProc
invoke CreateWindowEx, ...
invoke SetWindowLong, hChild, ; use just behind the line
GWL_WNDPROC, SubClassProc ; where you create your control
mov opEdit, eax ; the old pointer, see below

SubClassProc PROTO:DWORD,:DWORD,:DWORD,:DWORD ; move this line to proto section
°B3opEdit dd ? ; move this line to data? section

°B4SubClassProc proc hwnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
SWITCH uMsg

CASE WM_SIZE
return 0

CASE WM_MOVE
return 0

ENDSW
  invoke CallWindowProc, opEdit, hwnd, uMsg, wParam, lParam
  ret
SubClassProc endp