|
better I think you can use map<int nctrlid,="" int="" nyourvalue="">.
good luck,
Dror
|
|
|
|
|
In the name of GOD ?
You could do this a myriad of ways. You could ensure the ID's of the buttons were sequential, and then in your pretranslatemessage you could intercept id's within the range and store the value stripped of it's excess ( i.e. for 0 based subtract the id of button #1 from the value, for 1 based, add one to that ), you could put in handlers for each button ( more donkey work, but probably more robust ), you could use radio buttons, where a 0 based value is stored anyhow, you could use a struct, as has been suggested, etc. You don't need an algorythm, you just need to decide on a process.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hey Hadi,
Create a class that inherits from CButton and implement the OnClick event.
In the OnClick you should notify your parent that you have been clicked.
A simple way to do this would be to have your new class have the members:
HWND m_hwndWindowToNotify;
int m_iMessageToSend;
int m_iMyId;
Which you set when you create them all from the parent.
(I assume you have a variable length array)
So you set each CNewButton's hwndWindowToNotify to the parent.
The iMessageToSend to something like WM_USER+100 (which you don'y re-use!)
An m_iMyId as the number of the button (for ease on implementation).
CNewButton::OnClick()
{
::SendMessage(m_hwndWindowToNotify, m_iMessageToSend, m_iMyId, 0);
}
CParentDlg::OnCustom_SpecialButtonClick(LPARAM l, WPARARM w)
{
int iButtonIndex = (int)l;
// Do stuff for iButtonIndex button click
}
*** Don't forget to add ***
ON_MESSAGE(WM_USER+100, OnCustom_SpecialButtonClick)
to your parents message map (BEGIN_MESSAGE_MAP...)
Let us know how you go.
Jules
|
|
|
|
|
Here's a fun one -
Assuming MFC, you can use the ON_COMMAND_RANGE message map macro.
First, define all your buttons so that their ids are contiguous - i.e. IDC_BUTTON1 is 1000, IDC_BUTTON2 is 1001 etc.
Declare one handler as afx_message void MyButtons(UINT i) . Then use the range macro to send all of the buttons clicks to that fn:
ON_COMMAND_RANGE(IDC_BUTTON1, IDC_BUTTON50, MyButtons)
Remember to put this outside the //}}AFX_MSG_MAP stuff, but still inside the BEGIN_MESSAGE_MAP sandwich.
Then, your code can look like this:
void CTestDlg::MyButtons(UINT i)
{
}
i should hold the id of the button pressed.
|
|
|
|
|
Hi.
I Know that in Borland there're automatic .Bak files which are backup for any compiled file.
I was wondering if there're any such files in the VC++ 6.0 , and if not if there an option
to set VC++ to create back up files.
Thanks.
Gal.
|
|
|
|
|
No, but we could BUILD one ( spurious Black Adder reference )
To my knowledge, there isn't, but you can define a pre build or post build step, so it would be pretty easy to run something that did what you want, so it ran just before every build, or just after.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
HI All,
I have a situation where I need to have only one instance of a class at any given time. How would I do that. If you provide code it will be better. It is very urgent.
Thanking you
A.Santosh
|
|
|
|
|
|
Hi All,
I am trying to write an customised unistallation exe.
The problem I am facing is, after uninstallation,
the exe is left over..
So, I need to write a self destructing exe
which will destroy itself once uninstallation is complete.
Has any body tried this,
|
|
|
|
|
ummm
why not use the installers that are available?
installshield or the microsoft installer?
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
do you program clown chips?
|
|
|
|
|
i have a masters degree in them
along with clown fish
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
|
Thank you Jason. Excellent!
|
|
|
|
|
|
Is there a function or macro to convert an HRESULT to a win32 error code that can be set with SetLastError()? or can I just use the HRESULT value as the error code?
BOOL CMyWrapperClass::WrapperFunction()
{
HRESULT hr = IInterface.Function();
if (hr == S_OK) return TRUE;
DWORD error_code = Some_conversion_function(hr);
SetLastError(error_code);
return FALSE;
}
|
|
|
|
|
No. HRESULT values are determined by the server that produced them, they may or may not be standard Microsoft error values. You need to have the server's documentation to find out what HRESULT values mean.
|
|
|
|
|
There are some macros listed in the COM and MAPI docs that can extract the different portions of an HRESULT. Grep the MSDN for "Using Macros for Error Handling".
I think Mel has a point about their mapping to standard win32 codes - but at least you can get em.
There's also DECODE.CPP / .H. The readme warns that errors added after its release will not be recognized.
|
|
|
|
|
Thanks for the replies Where can I find DECODE.CPP / .H
I guess my best bet now would be to check all the HRESULTS returned from the functions and make sure they are defined in winerror.h before I do a SetLastError() with them, and change them to something close that is defined otherwise;)
|
|
|
|
|
The Decode sample is from 1996, but it should pop up if you search the MSDN for "DECODE.CPP".
I think there's a good chance a lot of the codes will map to win32, but it might be a grey area. There is a macro to map a win32 error to an HRESULT.
|
|
|
|
|
How does Onkeydown work???
I cant get my dialog to show a messagebox when i press the "S" key
I tryed lots of things, cant get it to work
I need some help or tip's
THANK you!!
|
|
|
|
|
You might want to look at OnGetDlgCode, which is a handler for the WM_GETDLGCODE message. If you override it for your dialog and return DLGC_WANTALLKEYS you might see a difference - check the docs for other constants.
Windows sends a window this message to see what it wants in terms of tab, arrows, etc. Note, for instance, that a dlg control might not ask for the tab char, since that would interfere with the hanling of the tab key by the parent dialog.
Mind, I would think 'S' would get through. Hmmm...
|
|
|
|
|
Is it possible to enumerate toolbars attached to a window? I have made a
program similar to SPY++ that comes with Visual Studio. It first enumerates
all processes, all threads, all thread windows, then all thread children. In all that mess
toolbar windows do no show up as children of anything. If you look at SPY++
and look at a program like Calcs children there are NO toolbars listed, only
controls like buttons and edit boxes.
I think I can FindWindows that are of a CtoolBar class but I don't think
that covers all cases and I don't know if I can relate it back to the
correct process let alone the correct window.
Thanks in advance,
Jason
|
|
|
|
|
I've noticed that sometimes dialog controls can show up in the list of top level windows for an application (usually custom creation code).
Also, apps often have more that one top level window, and contain controls that are created in other modules (COMCTL32.DLL, e.g.). I wonder if a call to GetTopWindow(NULL) and subsequent GetNextWindow(...) would find the toolbars.
Remember some windows have no parent, and even no owner, so you can't rely on all of an apps windows existing in an ancestral chain.
|
|
|
|
|
The following are defined global:
char *CmdTable[] = {"quit", "help"};
char *args[10];
I have a function called Search as follows:
int Search()
{
int iResult = -1;
int iEnd = 1;
int iCount = 0;
while (iCount <= iEnd)
{
if (args[0] == CmdTable[iCount]) return iCount;
iCount++;
}
return iResult;
}
and in main I call the function like this:
int iNum = Search();
Now, when going through the Search function and both args[0] and CmdTable[iCount] are equal to eachother it skips right over it as if they are not ... anybody know why that happens? I'm completely lost here because it should work!!
Thanks in advance, James
|
|
|
|