The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: allynm on December 17, 2009, 01:01:13 AM

Title: Problems writing text in a static window
Post by: allynm on December 17, 2009, 01:01:13 AM
Hello eveyone:

I use the following code to write a string to a static window:

invoke SendMessage, hwndStatic, WM_SETTEXT, 0, ADDR StaticText

The problem is that nothing gets written in the static window.  The static window is drawn, but the text string StaticText doesn't show up.

I create the static child window with this call:

invoke CreateWindowEx, NULL, ADDR ChildClass, NULL, \
        WS_CHILD or WS_VISIBLE or SS_BLACKFRAME or SS_CENTER,\
          300, 150, 100, 50,\
         hWnd, StaticID, hInstance, NULL

ChildClass is a db string "static".


Thaniks,
Mark Allyn
Title: Re: Problems writing text in a static window
Post by: hutch-- on December 17, 2009, 01:15:31 AM
Mark,

Remove the "SS_BLACKFRAME" style and see if it displays correctly then.
Title: Re: Problems writing text in a static window
Post by: allynm on December 17, 2009, 03:21:17 AM
Hello Hutch -

Blimey, it worked like a charm!  OK, now if you don't mind too much, what is there about the SS_BLACKFRAME that prevents the display of the text?  I searched and searched thru my Windows API reference (Rector and Newcomer) and couldn't find anything on this.

Thanks,

Mark Allyn
Title: Re: Problems writing text in a static window
Post by: MichaelW on December 17, 2009, 07:39:04 AM
Not all of the static control styles are intended to display text. SS_BLACKFRAME, for example, specifies a box with a frame drawn in the same color as the window frames. See Simple Graphics Static Control at the first link below.

http://msdn.microsoft.com/en-us/library/bb760767(VS.85).aspx

http://msdn.microsoft.com/en-us/library/bb760773(VS.85).aspx

Title: Re: Problems writing text in a static window
Post by: allynm on December 17, 2009, 01:00:06 PM
Hi MichaelW-

I looked at the two MSDN library items you sent.  Maybe I need to look again, but it seems to me they are both a bit ambiguous as far as writing in the static control.  I tried a couple of other frames and rects and can't write in any of them.  However, I can write reliably in a frame-less or unfilled control.  Is there no way to fill a static control with a color (or an icon or bitmap) and write in it too?

Thanks for your and Hutch's help on this.

Mark Allyn
Title: Re: Problems writing text in a static window
Post by: jj2007 on December 17, 2009, 01:43:56 PM
Have a look at \masm32\examples\exampl04\bmpbutn\bmpbutns.asm, Mark.
Title: Re: Problems writing text in a static window
Post by: allynm on December 17, 2009, 04:29:59 PM
Hello JJ-

Thanks for the tip.  I looked at the example.  It was very helpful.  There are also two very useful Procs that went with the example, esp.  TopXY.

Regards,

Mark Allyn
Title: Re: Problems writing text in a static window
Post by: MichaelW on December 17, 2009, 11:57:06 PM
QuoteIs there no way to fill a static control with a color (or an icon or bitmap) and write in it too?

The attachment demonstrates one method, and there are probably others.