News:

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

Static Control

Started by jckl, May 09, 2006, 03:20:18 PM

Previous topic - Next topic

jckl

If i am using a Static control and updating it every second then i run into a problem. Ill try to explain this the best i can. The static is getting the correct text but when the program is minimized or another window covers the static then i loose the text and it does not come back at all. If I place text in that static at the start of the application and do not update it then i have no problems. In my WM_CTLCOLORSTATIC message i have the following.


    cmp uMsg, WM_CTLCOLORSTATIC
    jne @F
     mov eax, lParam
     .if eax==hact || eax==hnact || eax==hgname || eax==hgtime || eax==hgtype || eax==hgmap || eax==hgstatus
       RGB 146,174,120
       invoke SetTextColor,wParam,eax
       RGB 57,88,41
       invoke SetBkColor,wParam,eax
       invoke GetStockObject, NULL_BRUSH
     .elseif eax==hcgname || eax==hcgtime || eax== hcgtype || eax==hcgmap || eax==hcgstatus
       RGB 235,235,230
       invoke SetTextColor,wParam,eax
       invoke SetBkMode,wParam,TRANSPARENT
       invoke GetStockObject,NULL_BRUSH
     .else
       invoke SetBkMode,wParam,TRANSPARENT
       invoke GetStockObject,NULL_BRUSH
     .endif
     ret
    jmp Return
    @@:


The handle to the static i am having a problem with is hcgname. I have not tried the others that are with that one yet but would imagine ill have the same problem.

hutch--

It sounds like you need to try the API InvalidateRect() when the window is restored or maximised to force a repaint of the static control.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Jackal

I have tried that but for some reason it still dont work. I even put it in the timer and forced the update. I see everything else flash but this static does not change still. I am not sure if maybe it is because it is on top of another static and maybe it is getting hidden behind but this other static control has a transparent background so i dont think that would be that cause of it.

Jackal

I have removed the other Statics and this did not solve the problem so that wasnt it. I have tried different things like getdc and createcompatibledc and such hoping I would get something to work and have not at this point. I starting to wonder if there is something i need in my WM_PAINT message like i did the background however I couldnt get anything to work and also the other Static controls seem to be just fine. Here is my WM_PAINT message to redraw the background color.


    cmp uMsg, WM_PAINT
    jne @F
      invoke BeginPaint,hWnd,addr ps
      RGB 57,88,41
      Invoke CreateSolidBrush, eax
      invoke SetBkColor,hWnd,eax
      invoke EndPaint,hWnd,addr ps
    jmp Return
    @@:

Shantanu Gadgil

Hello Jackal,
Just a hunch...is the resource ID of the "static control" in question same as some other control?
Could you post the "minimalistic complete" :toothy code which exhibits the above mentioned problem?
To ret is human, to jmp divine!

Jackal

I have the id set to NULL as I am using CreateWindowEx and also I have tried giving it an ID but still had the same problem. The application itself will not fill in the field at all unless you have a game called Delta Force Black Hawk Down. The source is posted at the link below if you would like to look at it. There are other strings in the app that could be displayed if you need to test it out.

http://www.joresources.com/other/lmm.zip

zcoder

Do you have a loop in your program that might need to be threaded?

if your program is in a loop updating the static control with text and a paint job needs to
to be done, the messages are not sent becouse your program is to busy, you can tell if
this is the case by watching your program from start to end, if there is a end to the updating
if it shows all the updates find but not when you move or resize the program, then this is
the case, then you will have to thread the part that is doing the loop or updating.


Zcoder....
Back in 1979, My computer ran so fine.
And there was no such thing,
As a Microsoft Crashed Machine.
http://zcoder.110mb.com
http://www.dietzel.com/partner/idevaffiliate.php?id=345_6  Free Domain Names

Shantanu Gadgil

To Jackal,
went throught the program...rewrote a small example similar to yours (without all the game related stuff of course :) ), it works OK at my place.

Could you strip your program to bare minimum with the problem you are facing?

Side note: Any specific reason you are NOT using .if-elseif for the message switch? Not too important, just makes it easier to look at the code.
To ret is human, to jmp divine!

Jackal

Sure i can strip it and post the problem i have. I have a feeling it may be as zcoder has said but we will have to see for sure. I am not sure if the timer is acting as a loop with the speed that it has set or not. Also i tend to use very few if.then.else as i want to eventually teach myself pure assembly but that will take some time.



Well i striped most the code and tested it to see if i have the same problem and it started working. I guess ill start commenting stuff out till i can find the cause of it. Thanks for the help and i will let you know if i have any other problems that i cant figure out  :U

Jackal

Ok i fixed the problem i was having with this but i have another question. I know i can use InvalidateRect on the entire window to make the static erase the old text and show the new text but it makes everything else flash. Is there a way i can make just this static refresh. I tried InvalidateRect with the handle of the static but it did nothing.

Jackal

I found something to work but i wanted to know if this is a bad way to do it. If you can give me input please do. Thanks..


    cmp uMsg, WM_CTLCOLORSTATIC
    jne @F
     RGB 235,235,230
     invoke SetTextColor,wParam,eax
     RGB 57,88,41
     invoke SetBkColor,wParam,eax
     RGB 57,88,41
     Invoke CreateSolidBrush, eax
     ret
    jmp Return
    @@:

Jackal

Ok i am still having a problem with this. It seems most my struggles are with the interface of the application and not the actual code that handles things. Anyway ill describe my problem and attach a project that shows my code and the problem i am having. I am using a static and have a tryed an edit with read only and disabled which is basically a static as i take it but it seems to be ok for a period of time and then my colors turn to default and i cant get it to stay my custom colors. I have tried many things but cant seem to make anything work. If i set a longer timer then it takes longer for the colors to disappear. I have tried to subclass the controls and put code in the paint message and such but nothin worked. If you can help or provide input please do.

[attachment deleted by admin]

Jackal

Anyone have any ideas as to why this happens and/or how to fix it?