|
Use the TBSTYLE_LIST style for the bar, and BTNS_AUTOSIZE for the buttons. I don't know if you can have different-width buttons for toolbars that don't have TBSTYLE_LIST .
--Mike--
Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
I am trying to subclass all buttons in all my dialogs, i have tryed a couple of soluions but nothing works, i have always a temporary handle.
I've tryed with FindWindowEx with "Button" in the class parameter but it doesn't work.
Has anybody an idea on how can i subclass all the buttons in all my dialogs at runtime ?
|
|
|
|
|
Why are you doing this? Are your buttons dynamically created or placed there with dialog editor?
CHAIGNEAU wrote:
I've tryed with FindWindowEx with "Button" in the class parameter but it doesn't work.
Maybe it's case sensitive try BUTTON
If you just have buttons, you could enumerate each window and change it's WndProc as you go.
If your buttons are all within a particular range of COMMAND id's you could also iterate each button control using GetDlgItem()
HTH
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|
|
My buttons are placed there with dialog editor.
I want to subclass dynamically all buttons in my application to draw them as i want without put a variable member in all my dialogs.
The className parameter of the FindWindowEx function is not case sensitive and i've tryed "BUTTON",i also get the className of a button and put it in this parameters but it still doesn't work.
How can you enumerate each child window of a dialog and now it's a button and then subclass them?
I don't want to change it's WndProc but change his class.
Thanx for your reply.
|
|
|
|
|
Honestly the easiest way to accomplish OWNERDRAW buttons is to derive a class from CButton and override it's DrawItem() and then use class wizard to associate each button with a Control member variable, then change each variable type from CButton to CYourOwnButton and whola!!! all yer buttons should be drawn the way you want
If you insist on using a more dynamic approach you could just make all your command ID's fall within a certain range of values and call GetDlgItem() return it's handle and subclass the control this way. Why would you use this approach though? Are you using SDK only...? Or just for efficiency?
HTH
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|
|
I want to build a generic framework to subclass all buttons. I can't use classwizard because my purpose is to not modify the existing app and to integrate this framework with less code as possible.
|
|
|
|
|
CHAIGNEAU wrote:
I've tryed with FindWindowEx with "Button" in the class parameter but it doesn't work.
Define "doesn't work." How about a code snippet of how you are using this function. Maybe the control does not exist at the time of the call.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I use this function in the Onitidialog, it's work for Edit, combobox but not button, it returns a NULL HWND.
|
|
|
|
|
Ok, but how are you calling FindWindowEx() ? Have you verified with Spy++ that the button has the characteristics you are searching for?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
What do you mean by "characteristics" ? FindWindowEx takes the handle of the window (my dialog), the handle of the window after we search or NULL, the class name (Button) and the window name or NULL. I've got the class name of a button of my dialog and passed it to the function but the return is still NULL, why ?.
|
|
|
|
|
CHAIGNEAU wrote:
What do you mean by "characteristics" ?
Characteristics aka properties aka attributes. For example, the class and caption of a window are part of its characteristics.
CHAIGNEAU wrote:
I've got the class name of a button...
Which is what?
CHAIGNEAU wrote:
...but the return is still NULL, why ?.
What does GetLastError() return?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Here is an eample :
HWND handle;
CWnd * pWnd = GetDlgItem(PB_REDRAW);
CString cs_Temp;
GetClassName(pWnd->m_hWnd,(LPTSTR)((LPCSTR)cs_Temp),100);
handle = FindWindowEx(m_hWnd,NULL,cs_Temp/*"Button"*/,"");
int err = ::GetLastError();
while (handle)
{
handle = FindWindowEx(m_hWnd,handle,cs_Temp,"");
}
this code is in the Oninitdialog and it works for edit, combo ... but not for buttons.
|
|
|
|
|
OnInitDialog()
{
CButton* pChild = GetWindow(GW_CHILD);
while(::IsWindow(pChild->m_hWnd)){
CString csClassName;
::GetClassName(pChild->GetSafeHwnd(), &csClassName, 6);
if(csClassName=="BUTTON"){
}
pChild = GetWindow(GW_HWNDNEXT);
}
}
This is what I had in mind
I'm drinking triples, seeing double and acting single
|
|
|
|
|
CHAIGNEAU wrote:
GetClassName(pWnd->m_hWnd,(LPTSTR)((LPCSTR)cs_Temp),100);
This is wrong, and is why I asked for a code snippet in my initial reply. The correct implementation should be:
GetClassName(pWnd->m_hWnd, cs_Temp.GetBuffer(100), 100);
cs_temp.ReleaseBuffer();
You should also set a breakpoint on the FindWindowEx() call and verify that cs_temp is "Button" before continuing.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I am trying to make an app which will act like the standard toolbar in Windows (i.e. always present, dockable)from the main window (i.e. not attached to a doc window) with application buttons. What is the best approach, use wizard and create dialog? Which class would be best to inherit from CDialog, CDialogBar, or CToolbar? Are there any examples out there which might help?
Thanks for the advice..
|
|
|
|
|
Is there anyone that has successfully used the mysql embedded server functionality? If so I would be very happy if you could supply some example code and/or point out known problems, quirks etc.
|
|
|
|
|
Have you looked at the examples supplied by MySQL
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Yes, I tried the samples and have no got them working. Still I got strange errors when debugging. The examples crash on mysql_server_end. Any clues?
|
|
|
|
|
Hi,
I want to scan a file which has special characters like eof character etc..
fp=fopen("input","r");
So if I use while((ch=fgetc(fp))!=EOF) it is not scanning the entire file.Is there any way to scan the files which has special characters.
Karteek
|
|
|
|
|
karteek wrote:
...it is not scanning the entire file.
How are you confirming this?
karteek wrote:
fp=fopen("input","r");
Have you tried using fp = fopen("input", "rb");
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
The code I wrote is:
FILE *fp1=fopen("input","rb");
FILE *fp2=fopen("output","wb");
char c;
while(1)
{
c=fgetc(fp1);
if(feof(fp1)) break;
fprintf(fp2,"%c",c);
}
fclose(fp1);
fclose(fp2);
But this code is not working
Karteek
|
|
|
|
|
karteek wrote:
But this code is not working
Define "not working."
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
The problem is that fgetc() returns an int, not a char.
Suggestion: instead of fprintf(), use fputc()
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
In windows, one solution is to search for "\r\n."
Kuphryn
|
|
|
|
|
Hi,
not working means it is not scanning the entire file.It is breaking out in between.Note the file has special characters like eof etc...
Karteek
|
|
|
|