|
Is this the way to get one handler to run but have different code executed depending on the menu item clicked? Is there some other technique?
In the OnMYMenu() handler, I did:
CString strA, strB, strC;
CString str1 = "A";
CString str2 = "B";
CString str3 = "C";
mmenu->GetMenuString(ID_PALETTEA, strA, MF_BYCOMMAND);
mmenu->GetMenuString(ID_PALETTEB, strB, MF_BYCOMMAND);
mmenu->GetMenuString(ID_PALETTEC, strC, MF_BYCOMMAND);
if(strA == str1)
{
dostuff();
}
if(strB == str2)
{
m_palette.bitCount = 0;
} etc
Thanks
Appreciate your help,
ns
|
|
|
|
|
Perhaps you should have a look at ON_COMMAND_RANGE for your message map. It's the "normal";) way to get the same function called for different menu items.
|
|
|
|
|
I'm on it.......it looks really cool! Now I'm trying to code it, but I do have a sample so I'm fairly certain I can do it. Many many thanks.....this was precisely what I needed.
BTW, whats your suggestion on getting dynamic menu items to run a function (no ID range is set since the number is not known at all .....) - cant use ON_RANGE for that....I tried doing win2Ks WM_MENUCOMMAND but no luck. Do you have any suggestions?
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
BTW, whats your suggestion on getting dynamic menu items to run a function (no ID range is set since the number is not known at all .....) - cant use ON_RANGE for that....I tried doing win2Ks WM_MENUCOMMAND but no luck. Do you have any suggestions?
I'm not sure whether it really works (because never needed it) but I think overwriting CWnd's OnCommand could work.
|
|
|
|
|
Question: Do you think the compiler etc can handle it if I set aside say 500 IDs ?
Can I do this: in resource.h
#define ID_START 5000
#define ID_END 5500
Then as I go through doing AppendMenu
for (int i = ID_START; i < ID_END; i++)
{
psubMenu->AppendMenu(MF_STRING, i, tempSub);
}
Then I could use the On_COMMAND_RANGE....
Appreciate your help,
ns
|
|
|
|
|
Uhm ... I must admit I never thought of such a solution. but as I see it, it could work, provided that there's no other ID defined between 5000 and 5500. Give it a try and you'll know whether it's practical or not.;)
|
|
|
|
|
I want to use 'iphlpapi.h' (I want to be able to use GetAdaptersInfo) in a MFC application, but I get this message:
Cannot open include file: 'iphlpapi.h'
What can I do?
Thanks
-- n
|
|
|
|
|
install the platform SDK (see msdn.microsoft.com/sdk[^])
Holy Sh*t! I'm speechless. (hey, that's a first) Marc Clifton, The Lounge
|
|
|
|
|
Thanks, I just realized after posting this question.
Sorry!
Thanks a lot.
-- n
|
|
|
|
|
Yes, I just installed the SDK.
But I get this error:
c:\program files\microsoft visual studio\vc98\include\iphlpapi.h(183) : error C2065: 'PMIB_ICMP_EX' : undeclared identifier
Any ideas.
Thanks
|
|
|
|
|
It's solved including the right directories in tools / options / directories.
Thanks
|
|
|
|
|
Is it possible to do it ?
I created a CButton in a dialog, and made it a CBitmapButton :
CBitmapButton myButton;
...
DDX_Control(pDX, IDC_OPTION_PANEL_CHECKBOX, m_myButton);
...
BOOL myDialog::OnInitDialog()
{
CDialog::OnInitDialog();
myButton.SetButtonStyle( BS_AUTOCHECKBOX );
myButton.LoadBitmaps(IDB_SHOW_HIDE_OPTION_PANEL_UP,IDB_SHOW_HIDE_OPTION_PANEL_DOWN );
myButton.SizeToContent();
...
}
If I do SetButtonStyle( BS_AUTOCHECKBOX ) I loose the bitmaps and the button becomes a simple checkbox button.
Did I miss the obvious ?
Thanks.
Max.
|
|
|
|
|
Hi,
I want to use this control in my win32 program (not mfc) through rc file.
When I use this control, the dialog box is not displaying.
Can anybody help please?
RC file excerpts:
CONTROL "",IDC_LIST1,"SysListView32",LVS_ALIGNLEFT | WS_BORDER |
WS_TABSTOP,81,10,60,50
Thanks in advance.
Regards,
Shivpal
|
|
|
|
|
void InitCommonControls(VOID);
|
|
|
|
|
Yes. I did it and its working now
Thanks a lot
Shivpal
|
|
|
|
|
WHy is this happening?
I have:
CImage & ImageRemus = m_PaletteMap[m_PalRemus];
If I put a breakpoint at this line and step in ,it crashes if I try to advance to next line of code (step over).
But if I put a breakpoint in the destructor of my CImage class, and say run to next breakpoint from this first breakpoint, it steps into the destructor!!!! (It crashes there).
Question is why is it stepping into the destructor?
Appreciate your help,
ns
|
|
|
|
|
There is not enough information, so I am going to guess.
1. member at position m_PalRemus does not exist.
2. CImage default constructor does not initialize object properly OR you did not overwrite copy constructor.
Could you show the whole function and exact declaration of the map. The declaration of CImage would help too.
|
|
|
|
|
Hi Alex,
I stil dont know why it went into the destructor. But I found out that I hadnt initialized a member in the constructor, so it was pointing to some invalid address. Then in the destructor I was having it delete that pointer if it existed. It did exist because it wasnt initialized and then it tried to delete it. The big mystery is --- why did it even go into the destructor in the first place? After i fixed the error (omission), and put breakpoints in the destructor, the program never did venture into the destructor .....puzzled.
Appreciate your help,
ns
|
|
|
|
|
Here is simplified explanation
std::map<key, type=""> operator[]:
1. check if member at Key position exist (same as calling map::find(Key))
2. if does not exist create new value
a. Create temporary object of Type (call to Type::Type() constructor)
b. Copy the temporary obect to the position [Key](call to Type::Type(const Type &) constructor)
c. Destroy temporary obect(call to Type::~Type())
3. Return Type& to the element at Key position
|
|
|
|
|
Thats really clarified the process to me. Thank you so much....now it makes perfect sense!!
Appreciate your help,
ns
|
|
|
|
|
the definition of std::map<>::operator[] says it returns value of insert(value_type(key, T())) .
this value_type(key, T()) creates temporary T object (CImage in your case) using default constructor. This temp object is destroyed when operator[] exits, therefore the destructor is called.
|
|
|
|
|
Thanks. I get it now...
Appreciate your help,
ns
|
|
|
|
|
here is my problem:
<br />
<br />
Class test<br />
<br />
void test::showmsg<br />
{<br />
AfxMessageBox(m_msg);<br />
}<br />
<br />
function thread<br />
<br />
UINT testThread(LPVOID param)<br />
{<br />
?????? ctrl = class mainclass control ??????<br />
<br />
for (int i = 0; i < 100; i++)<br />
{<br />
ctrl->m_msg.Format("%d", i);<br />
ctrl->showmsg();<br />
}<br />
<br />
return 0;<br />
}<br />
<br />
this is a simple example of what i want to do, the thread is gonna be a connection with a network.
|
|
|
|
|
When launching the thread, give this as parameter.
Then with a CMainDlg *ctrl = (CMainDlg*)param; (instead of the line where you put ?????)everything should be fine.
~RaGE();
|
|
|
|
|
You should pass a pointer to your class test when calling AfxBeginThread, supplying the pointer as second parameter.
in test, where starting your thread:
AfxBeginThread(testThread, (LPVOID)this)
|
|
|
|