Click to See Complete Forum and Search --> : GetClassName Function


Erik Wiggins
February 21st, 2005, 06:55 PM
#define MAX_LOADSTRING 50

TCHAR szButtonCls[MAX_LOADSTRING];
LoadString(hInstance, IDC_BUTTON, szButtonCls, MAX_LOADSTRING);

hButton=CreateWindowEx(NULL,szButtonCls, "BUTTON",WS_VISIBLE|WS_CHILD|BS_PUSHLIKE|BS_OWNERDRAW,0,0,15,15,hPallete, NULL, hInst, NULL);
if (!hButton) return FALSE;

ShowWindow(hButton, SW_SHOWNORMAL);
UpdateWindow(hButton);

TCHAR szCls[MAX_LOADSTRING];
GetClassName(hButton,szCls,MAX_LOADSTRING);
If(szCls==szButtonCls)
{
//Do Something
}
for some reason the last statement If(szCls==szButtonCls)
is returning false. Any ideas on how to fix it?

ovidiucucu
February 22nd, 2005, 04:08 AM
First of all szCls==szButtonCls compare two pointers and not two strings.
Call _tcscmp instead.
Moreover, something seems to be shuffled in CreateWindowEx.
The second argument must be a registered class name.
Is szButtonCls a registerd class name or your intention is to create a window of class "BUTTON" ?

Erik Wiggins
February 22nd, 2005, 06:58 AM
the szButtonCls holds the class name "BUTTON" the window name is also "BUTTON". When I use GetClassName(hButton,szCls,MAX_LOADSTRING); it's loading "Button" into the szCls. So if(_tcscmp(szButtonCls,szCls)) is returning false. What I am trying to do is destingush the class of the child control in a EnumChildProc so I can paint the Owner drawn buttons but not the Static and edit controls on the same pallete window.

ovidiucucu
February 22nd, 2005, 10:23 AM
Oups... sorry!
Use _tcsicmp that performs a lowercase comparition (so is not case sensitive).

Erik Wiggins
February 27th, 2005, 04:34 AM
If(_tcsicmp(szCls,szButtonCls)==0)

returns the desired resualts thanks alot for all the help.