Title: Question about font and edit controls
Dragon - June 30, 2003 06:16 PM (GMT)
Xception, when I used your example for setting the font of a control, only one of the controls was affected. The rest still had the default font. Can you give me an example of setting the fonts of all controls?
Also, with the GetWindowText function, can only char types be returned? I tried using int, but Dev-C++ reported that there was an invalid conversion from int to char, so I assumed only char can be used. Another question about edit controls, how can I clear the contents of the control? I can get the contents now, but I don't know how to clear it.
dr voodoo - June 30, 2003 07:37 PM (GMT)
OK with
| CODE |
| HFONT [I]newfont[/I]; |
you can store a font.
With
| CODE |
| [I]newfont[/I]=CreateFont(22,0,0,0,400,0,0,0,0,0,0,0,0,"Dauphin"); |
you can create/load a font and store it in memory.(check the arguments in some reference)
| CODE |
| SendDlgItemMessage(hwnd,[I]ID[/I],WM_SETFONT,(WPARAM)[I]newfont[/I],true); |
Will send a WM_SETFONT message to the child window of hwnd (which often is our main window). We set the ID when we create our window
| CODE |
CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 0, 0, 0, 0, hwnd, (HMENU)[I]ID[/I], GetModuleHandle(NULL), NULL); |
So you simply have to send such a message to all your EDITs.
PS: An EDIT is a sort of window
| QUOTE |
| Also, with the GetWindowText function, can only char types be returned? I tried using int, but Dev-C++ reported that there was an invalid conversion from int to char, so I assumed only char can be used. Another question about edit controls, how can I clear the contents of the control? I can get the contents now, but I don't know how to clear it. |
If I remember well there is a function called GetWindowInt and it will return an int type. But I could be wrong here. Best look it up in a reference.
To clear you simply put an empty string in there.
Dragon - June 30, 2003 11:17 PM (GMT)
I know it's a type of window. That's why you create it using CreateWindow. Thanks for the help, however.
dr voodoo - July 1, 2003 12:02 PM (GMT)
You have to set the font of each single EDIT box and to do so you need to sent it a WM_SETFONT message to that EDIT-window. So you declare a font and to post the message you can simply use SentMessage() or PostMessage(). WPARAM must be your font and LPARAM must be true. I don't know why but it's simply that way.
Dragon - July 1, 2003 04:09 PM (GMT)
[QUOTE]If I remember well there is a function called GetWindowInt and it will return an int type. But I could be wrong here. Best look it up in a reference.
To clear you simply put an empty string in there.[QUOTE]
I tried GetWindowInt, but that doesn't work. I tried using GetWindowText, but I need to clear a string, and not limited to several characters (set by doing char value[3] or something else).