Thread: Few Questions (Styles, Static Control)

  1. #1
    #junkie
    Join Date
    Oct 2004
    Posts
    240

    Few Questions (Styles, Static Control)

    Ok, well as you can see from my image and source file, i'v got a simple window setup with no message returns and junk yet.

    However i'v ran into a few snags, as usual.

    1.) How can i send text to static Boxes? I want to use the two top boxes to simply hold a truely static string, as in it wont change after i set it. And the bottom box, i want to use as a umm.. display box? Displaying what the program is doing, loading, saving, ect. Just a simple no scroll display with multiple lines, each line being a new message.

    Anyway, how can this be done? i tried sending it
    Code:
                SendMessage(hMainStatic_Name, WM_SETTEXT, 0, (LPARAM) lpszTrouble);
    however that seems to get my nothing, and "lpszTrouble" is a character array holding a string, this is the same way i pass text into the edit box (for testing) which works,and the article on Static Controls says to pass in a character pointer into the LPARAM, and i havent been able to get the pointer to specifically regonize the character array. I'm a bit rusty on coding and forgot how to point to an array ( i thought i just pointed to the variable address but aparently i'm wrong, so comments on the following code would be helpful too lol)
    Code:
                CHAR lpszTrouble[] = "Zeusbwr";
                CHAR * ptString[] = 0;
                ptString = &lpszTrouble;
    
    *error "170 C:\path\main.cpp cannot convert `CHAR (*)[8]' to `CHAR*' in assignment"
    So anyway, help on getting text into the static box would be awesome.


    2.) I am having multiple problems just dealing with the look of my boxes. Like Fonts, i am unable to find a font Message/Style to change the default font for my Editbox, ComboBox, and i am sure my Static Boxes once i get them working. Fonts, Font Size, Bold/Not, and Itallics, is any of that predefined in a message or anything?

    3.) Again, on the look of my editbox. You know how static boxes have messages to change the apearence of the box? Like giving it a dark frame with SS_BLACKFRAME or changing the background color of the Box with SS_WHITERECT? Is this possible with the Edit Control? My edit control has a white background with no "Frame" (unless the frame is matching the background color of the window, i wouldent know then obviously), how can i change this?


    Thanks to any replies!
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    1. You probably don't have the right style settings for the edit box, because WM_SETTEXT should work.

    2.
    Code:
    // Create font
    #ifndef CtFont
    #define CtFont(hDC, iHeight, iStyle, achFace) \
    	CreateFont(-MulDiv(iHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72),0 ,0 ,0 ,iStyle ,0 ,0 ,0 ,1 ,OUT_DEFAULT_PRECIS ,0 ,PROOF_QUALITY ,0 ,achFace)
    #endif
    3. Don't know if WM_CTLCOLORSTATIC/WM_CTLCOLOREDIT is what you're looking for?

  3. #3
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    Quote Originally Posted by knutso
    1. You probably don't have the right style settings for the edit box, because WM_SETTEXT should work.
    Well first off, do you mean edit box or static box? Because WM_SETTEXT works in my edit box, but my static boxes i was having trouble.
    Second off, i think i found it in a dif form.
    Code:
    SetWindowText(hWndStatic, "Static Text")
    Different form, and if anyone is willing to look at my source file to see why WM_SETTEXT isnt working (because thats what the Article on MSDN told me to use), id be really appreciative, thanks for the reply and any future



    Quote Originally Posted by knutso
    3. Don't know if WM_CTLCOLORSTATIC/WM_CTLCOLOREDIT is what you're looking for?
    *edit*
    And yes, it seems it is. Except that reads like it just colors the background of an editbox, is there a way to frame it? Because id be happy with the default white background if i could just give the edit control a Frame..

    Thanks again
    Last edited by Zeusbwr; 04-14-2005 at 01:37 AM.
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    Do you create your controls from resources, or from CreateWindow()?

  5. #5
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    CreateWindow();, if you wanna see everything my source is included in the first post

    But ya.. is CreateWindow a problem?


    *edit*
    and ya..
    Code:
    SetWindowText(hWndStatic, "Static Text")
    didnt work either, it didnt return null (if (!SetWindow ect...).. so i dunno
    Last edited by Zeusbwr; 04-14-2005 at 12:34 PM.
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  6. #6
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    you can give the edit control a frame by giving it the style WS_BORDER.

    edit: also, I have just noticed, if you comment out the SS_BLACKFRAME style, everything works as normal. you should remove this and replace it with WS_BORDER. it will produce the same effect. However, if you want to keep the background of the static controls white, you will have to handle WM_CTLCOLORSTATIC.

    edit2: here is why the text isn't being displayed (from msdn):

    Frame Styles
    Static controls can be used to draw frames (boxes that are not filled). Frame-style static controls do not display text. The three frame-style static controls are:

    SS_BLACKFRAME
    SS_WHITEFRAME
    SS_GRAYFRAME
    sorry about all this editing

    edit3: here's some code to set the font of a control:

    Code:
    			////////////////////////Create The Font////////////////////////////
    			LOGFONT lf;
    			GetObject( GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf );
    			strcpy(lf.lfFaceName,"Comic Sans MS");
    			HFONT hfDefault = CreateFontIndirect( &lf );
    			///////////////////////////////////////////////////////////////////
    
    			SendMessage(hMainStatic_Name,WM_SETFONT, (WPARAM)hfDefault, (LPARAM)true); //Set font
    good luck.

    -r1ck0r
    Last edited by r1ck0r; 04-14-2005 at 01:04 PM.

  7. #7
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    Ok, thanks! I can finally add text to my static controls lol. Now the question is, how can i add boarders around my static windows while having text lol..

    I spose maybe i could layer an empty static behind it slightly bigger with a boarder..

    Anyway, any ideas? Or maybe i should just banish all of this and use user drawn Edit, Static, Combo, and Radio Buttons? What do you all think?
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  8. #8
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    In my above post I stated that you can replace SS_BLACKFRAME with WS_BORDER and get the effect you are trying to achieve, yet while still maintaining the abilty to change the static controls text. I apologize I know my post is rather messy due to all that editing

    BTW, Owner Drawn controls are a little over the top for something like this. Especially when there are easier methods available.
    Last edited by r1ck0r; 04-14-2005 at 01:45 PM.

  9. #9
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    Oh sorry, i thought that was only for the edit controls. Thanks
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  10. #10
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    WS_=windowstyle=for all windows.

  11. #11
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    awesome

    That include Dialog?
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  12. #12
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    yes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do i do this? (static structure inside class)
    By 39ster in forum C++ Programming
    Replies: 4
    Last Post: 11-17-2008, 03:14 AM
  2. Changing static control text color
    By maxorator in forum Windows Programming
    Replies: 6
    Last Post: 11-03-2005, 10:03 AM
  3. A few questions on ListView Control...
    By Devil Panther in forum Windows Programming
    Replies: 0
    Last Post: 09-05-2003, 02:33 PM
  4. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM