|
True, but mangled code or not, if only one listbox exists on the dialog, the outer loop will indeed fire an assertion. That's why I asked him for clarification.
Heck, it'll probably be something cheesy like an 'i' not being dotted, or his shoelaces not being tied.
|
|
|
|
|
|
for( int i=0; i for( int j=0; j<10; j++ )
{
str.Format( "Station %d", j+1 );
m_List[i].AddString(str);
}
is it me, or is there no incrementation for i? i've never seen a for loop like this before. :-/
*.*
cin >> knowledge;
|
|
|
|
|
keegan wrote:
is it me, or is there no incrementation for i? i've never seen a for loop like this before.
There is always a first time.
It seems to me that the he/she didn't type < correctly. If it is entered directly from the keyboard the scripts of this page will consider the words inside the greater sign as html tags.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
An easy one for all you experts.
I have a class derived from CFrameWnd, how do I set the Icon on the top left of the window ?
I found out I have SetIcon method there, but where do I get HICON and how do I set it to be an Icon I created.
Shay
|
|
|
|
|
use the LoadIcon API!
Don't try it, just do it!
|
|
|
|
|
OK, but.....
If I write it this way:
<br />
SetIcon(::LoadIcon(NULL, IDI_QUESTION),true);<br />
I will not be able to use my icon an I will be restricted to the default MFC ones, such as IDI_QUESTION.
Any way to load my icons ?
|
|
|
|
|
The MFC ones can be deleted using the Resource editor and you can import your own icons or cut and paste bitmap images into an icon resource made in the editor, this will compile the icon into your exe so you can use LoadIcon, which is better than having .ico files littered around. Have a gander with the resource editor to create your very own custom icon
|
|
|
|
|
hIcon = (HICON) ::LoadImage(NULL, _T("my_own_icon.ico"), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
SetIcon(hIcon, TRUE); SetIcon(hIcon, FALSE);
Easy indeed
|
|
|
|
|
Hi,
I would like to have my menu item to have a check next to it as it displays windows. In other words, if the window that is launched by the menu item is not NULL, then I want a check next to it and if not i don't want the check to be next to the menu item.
I can get it to be unchecked at app start up and checked when the menu item is first selected. I am having problems on how to uncheck the item when the window is closed.
Any help you be appreciated.
Thanks in advance.
|
|
|
|
|
Did you have a look at FAQ [^]?
When you handle UPDATE_COMMAND_UI in the class wizard you do something like this:
void CMyApp::OnUpdateMyMenuItem(CCmdUI* pCmdUI)
{
pCmdUI->Enable( DisplayedWindow == NULL );
pCmdUI->SetCheck( DisplayedWindow == NULL );
}
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Hi,
I don't want to disable the window, i just want the menu item to be unchecked whenever the window is closed. I got it to be checked, just can't get it unchecked.
I searched but didn't find what i was looking for.
thanks for the suggestion. Any more help would be appreciated.
|
|
|
|
|
Jay Hova wrote:
I got it to be checked, just can't get it unchecked.
This is what pCmdUI->SetCheck( DisplayedWindow == NULL ) does (actually it should be DisplayedWindow != NULL). When you close your window have a pointer that refers to that window and set it to NULL. DisplayedWindow supposedly is a pointer that you should declare and initialized when you create the window and destory it when you close the window.
In my code if DisplayedWindow != NULL evaluates to true then the menu item will be checked, otherwise it will be unchecked. Check CCmdUI class.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Here is the answer you were probably looking for, but until now, didn't get
in the new dialog class add this function. Now the new dialogs will control that menu item in it's parent.
void MyClass::checkmymenuitem(int checked)
{
CMenu* pMainMenu = GetParent()->GetMenu();
CMenu *submenu = pMainMenu->GetSubMenu(1); // replace 1 by the horizontal menu position
UINT g = submenu->GetMenuItemID(3); // replace 3 by the actual vertical item position
CString mnustr;
submenu->GetMenuString(3, mnustr, MF_BYPOSITION); // replace 3 by the actual vertical item position
// you can optionally change mnustr to a text here
if (checked) submenu->ModifyMenu(3, MF_BYPOSITION | MF_STRING | MF_CHECKED, g, mnustr);
else submenu->ModifyMenu(3, MF_BYPOSITION | MF_STRING | MF_UNCHECKED, g, mnustr);
}
in initdialog
checkmymenuitem(true);
then in onclose
checkmymenuitem(false);
|
|
|
|
|
Beer26,
This is what i want...but I still have a problem.
I put in the code that you gave me and it works fine at start up and the first time that the menu item is selected. But if i close the window and the select the menu item again, it doesn't update with a check mark the second time. Am i doing something wrong or is there something else that needs to be done?
Thanks for the help btw, i really appreciate it
|
|
|
|
|
"it doesn't update with a check mark the second time."
It should, you could make sure that the 2nd windows's parent is the window with the menu, and you could put some code in there to make sure the pointers aren't NULL;
|
|
|
|
|
hello people
my question is how do i make my software secure that is i have this application which i want the users to use for it a limited after which they must have a license how i do write code so that the application expires in a particualar time i heard that softwares that expire with time write something on the registry so dont you think anyone can just open up the registry and edit the setting and make the software work forever so how to make it secure any methods anyhing would be appreciated and also after the user has acquired a license where do i keep the license information and all please help
regards
Ahmed Ajmal
|
|
|
|
|
lol.... no comma, no full stop, complete chaos!
Don't try it, just do it!
|
|
|
|
|
Check out this link http://www.codeproject.com/system/cexpire01.asp?target=cexpire[^].
If you want to store data in the registry, encrypt it, and put in a location that is not obvious.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Cyberizen wrote:
anyone can just open up the registry and edit the setting
Not anyone, very few people actually understand how to work with registry.
Very, very, very few people are capable of hacking into binary encrypted data (assuming that you wright binary encrypted data into the registry). From my experience there is no such thing as absolutely secure system, however RC2 and other encryption algorithms are pretty close.
|
|
|
|
|
Hi all, I have a dilemma involving message handling. Basically I'm writing a game and have created a frontend in its own thread. To avoid multithreaded render problems the application always calls the frontend when it is required to be rendered. However, I would like the frontend to track all the keyboard and mouse messages (not the app) when the frontend is active, but the app should process them when it is inactive (to move the character etc.). I have not yet implemented directinput (though I am using directx), though maybe it is about time I did. What I would like to know is how to have my frontend feeding on mouse and keyboard messages sent to the app when its active, and stop when its inactive. I had a look at SetWindowsHookEx but this only gets activated when the app uses PeekMessage and the whole purpose of having my frontend in another thread spying on mouse and keyboard messages was so that lengthy renders don't inhibit the mouse and keyboard events. Any ideas or advice would be appreciated in this respect.
Many Thanks,
Alan.
|
|
|
|
|
Use the keyboard and mouse hooks instead.
John
|
|
|
|
|
You mean MouseProc (and KeyboardProc presumably)? Looking at this in MSDN it still waits for the app to peekmessage with a relevant message pending. I seem to be in a catch 22 where I want the frontend to handle message pumping when it is active and the app to handle it when it is not, I think a way of re-routing messages to a thread is perhaps what I need (so when the frontend is activated the messages are routed to that thread and when it is deactivated it is re-routed to the app thread). Not sure how to do this, or if its even worth it? What do ya reckon?
Thanks for the info though
Alan.
|
|
|
|
|
You mean MouseProc (and KeyboardProc presumably)? Looking at this in MSDN it still waits for the app to peekmessage with a relevant message pending. I seem to be in a catch 22 where I want the frontend to handle message pumping when it is active and the app to handle it when it is not, I think a way of re-routing messages to a thread is perhaps what I need (so when the frontend is activated the messages are routed to that thread and when it is deactivated it is re-routed to the app thread). Not sure how to do this, or if its even worth it? What do ya reckon?
Thanks for the info though
Alan.
|
|
|
|
|
read about the SetWindowsHookEx API in MSDN, and dont repeat urself
Don't try it, just do it!
|
|
|
|