News:

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

MODELESS DIALOG BOX

Started by Grincheux, March 03, 2005, 07:53:11 PM

Previous topic - Next topic

Grincheux

I have a modeless dialogbox in which I show the items I am receiving from a server.
When I switch to an other program and then come back to my dialogbox, this one
does not show any thing.

What is there special to do with modeless dialogboxes ?


Thanks

Kenavo
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

pbrennick

IDCat,
There isnothing special required thatI know of.  I use this type ofdialog all the time becauseI like to switch back and forth between the dialog and the main window such as when I am doing progressive searches.  Repainting is automatically handled.  Repainting is your problem and either there is a problem with the app or your resources are very low.  Can we look at the code or can you give us the exe for testing?

Paul

Grincheux

Here is the source code :

ReceiveDlgProc            PROC      USES EBX EDI ESI,hWin:HWND,uMsg:DWord,wParam:WPARAM,lParam:LPARAM
                     LOCAL      szTemp[1024]:Byte

                     mov         eax,uMsg

                     cmp         eax,WM_ACTIVATE
                     jne         @F

                     cmp         wParam,WA_INACTIVE
                     je         WmActivate_Inactive

                     mov         eax,hWin
                     mov         hActive,eax
                     jmp         ReceiveDlgProc_End

WmActivate_Inactive :

                     mov         hActive,NULL
                     jmp         ReceiveDlgProc_End

@@ :

                     cmp         eax,WM_INITDIALOG
                     jne         ReceiveDlgProc_WmCommand

                     push      IDC_STATIC_01
                     push      hWin
                     push      OFFSET $ + 10
                     jmp         GetDlgItem

                     mov         hCtrl_15,eax

                     xor         eax,eax
                     inc         eax
                     jmp         ReceiveDlgProc_Exit

ReceiveDlgProc_WmCommand :

                     cmp         eax,WM_COMMAND
                     jne         ReceiveDlgProc_End

                     movzx      eax,Word Ptr wParam

                     cmp         eax,IDM_RECEIVE_01
                     jne         ReceiveDlgProc_End

                     push      lParam
                     push      OFFSET szFmt_002
                     lea         eax,szTemp
                     push      eax
                     push      OFFSET $ + 10
                     jmp         wsprintf

                     add         esp,12

                     lea         eax,szTemp
                     push      eax
                     push      0
                     push      WM_SETTEXT
                     push      hCtrl_15
                     push      OFFSET ReceiveDlgProc_End
                     jmp         SendMessage

ReceiveDlgProc_End :

                     xor         eax,eax

ReceiveDlgProc_Exit :

                     ret
ReceiveDlgProc            ENDP

; #########################################################################

Receive_Dialog            PROC      USES EBX EDI ESI,hWin:HWND
                     push      NULL
                     push      OFFSET ReceiveDlgProc
                     push      hWin
                     push      DLG_RECEIVE
                     push      hInstance
                     push      OFFSET $ + 10
                     jmp         CreateDialogParam

                     mov         hWndReceive,eax
                     mov         hActive,eax

                     ret
Receive_Dialog            ENDP

The main message loop for the application has been modified to handle modeless dialogboxes.

I wonder if the WM_ACTIVATE message is OK. I am not sure but I think that the problem I have found comes with this message.


Thanks


Kenavo
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

pbrennick

Hi Kenavo,
Withut seeing the program, it is hard to tell what is happening.  From my own experience in using that particular message; if the result is that the dialog box is going active, I will usually issue a SetFocus.  If you do a SetFocus, the dialog box will repaint itself.  So whynot add a SetFocus?

Paul

Grincheux

I have to add a "SetFocus" to the WM_ACTIVATE ?

Why not.

I'll try at home tonight.

I'll send you the program too.
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Grincheux

//

Here is the fullproject. Program and source code in a WINRAR archive.

Good luck



[attachment deleted by admin]
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

pbrennick

IDCat,
First of all, that is a very professional application!  Having said that, I have tested it and Ihave been able to duplicate (I think) the effect that you are referring to).  I do not believe that you have a problem, here.  What I thinkis happening is when network traffic is busy, the application cannot update the screen.  For example, I start my File Manager and then start your app.  I tell your app to connect and then alt-tab to my file manager.  If I immediately alt-tab back to your app, the dialog box will not refresh until the connect or a timeout occurs.  This is normal behavior, IMO.

Paul

Grincheux

Thanks for your comments.

The problem you describe is exactly the problem I meet.

And I have no solution too.


Philippe RIO
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Rifleman

IDCat,
The problem is that you are giving control to another process.  At that point, you are at the mercy of it.  You cannot even ask it to abort because it is not 'looking' at your message queue at that point.  Once it is done with its task, it will look 'your way' and say 'hey, what's up!/'  While writing programs to run on a Novell server, this always drove me nuts.  I once posted a question about it and was told that it is because something meaningful could be happening via another connect and allowing me to interrupt it would not be a good thing.

Paul

Grincheux

I meet an other problem which looks like this one : I am filling a treeview with more than 40000 groups.
Windows never updates the treeview while I am filling it.
When I finished, the treeview appears.

One question : If between two insertion I have a delay (sleep function), does the treeview becomes good ?
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Rifleman

IDCat,
I am not sure about the treeview thing as I have not tried that.  Logically, it seems sound.  Why not try it and you tell us? :toothy  About the network timeout, one last thought.  I suppose you could change the beacon count on your end.  This would cause a quicker disconnect on timeouts but because this could generate false positives, it is never recommended to tamper with it.

Paul

Grincheux

I have tried with the sleep function, this is not good. The sleep function suspend the thread so this can explain why I don't happen.
I have tried with a loop, initializing EDX and EAX to -1, the result always is bad.
Now I am trying with a timer.

Philippe RIO
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Rifleman

IDCat,
Have you tried lowering its priority?
Paul

Grincheux

No.

And with a timer I have NO SUCCESS.
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Mark Jones

...Could you get, say, 1000 groups at a time, refresh the window, get 1000 more, refresh, etc?

What about putting the problem code into a second thread? That way your program is free to process window messages (redraw, etc) while the other thread completes. I'm a noob so be warned! :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08