|
You did answer the question (according to way I asked it). Thanks!
However, in actuality where things began going murky for me, is when I'm inside Foo() I make a change to "day" (the object of "Day") by giving it a different value when I'm about to exit. This I do by including in the definition of "Day" a generic value (let's call it "anyday") so that every time I call Foo(), I don't have to use a specific value, I just use "anyday" and check its value inside Foo() to see what the specific value is that I really need. I do this to avoid having to hard-code a specific "Day" value in the function parameter every time I call Foo().
IOW, I assign the new value to "anyday" while I'm inside Foo(), using "anyday" as my parametric value and then check "anyday" to see what the specific value is that I had assigned to it when I was previously inside Foo(). (I think I might be outsmarting myself here, because the compiler accepts the code as well.)
That is what I meant to ask, but made it sound in a way I believe I may have misled you. It was inadvertent and I regret any mislead.
While it is true that the compiler is accepting my code, I believe I might be abiding by the rules of C++, but not by its intent.
William
Fortes in fide et opere!
|
|
|
|
|
Remember that changes to formal parameters have no effect on the caller's variable, unless you're using a reference.
--Mike--
"Big handwavy generalizations made from a position of deep ignorance is one of the biggest wastes of time on the net today.
-- Joel Spolsky
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Halo, I still have problems with list box..
The idea is to have a set of data in a list box..like..list1, list2 ,list 3...etc,
and then to retrieve the data which was clicked,
I have created list box but i dont know how to fill it in with data,
BOOL CdcsetDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CString str;
for( int i=0; i
|
|
|
|
|
Have you create d the listbox before filling them ?
how are they created, in a resource file or dynamically ?
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
You need to be more specific about your problem? What is the Assert msg? Where is it?
You appear to be mixing different loops in your code here as you have two for loops intertwined where the code refers both to i and j and it's not obvious what you're trying to do.
1. Add a ListBox to the dialog
2. Create a DDX variable by right clicking the control and selecting Add Variable.
3. Variable name = m_List (to match your code) - You'll also need to delete your own manually defined m_List
You should now be able to add and remove items as well as respond to user events.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Deepak Samuel wrote:
I have created list box but i dont know how to fill it in with data,
...
m_List[i].AddString(str);
The former of these two statements is singular, while the latter is plural. So do you have more than one listbox on the dialog?
|
|
|
|
|
I'd be willing to bet that if you look at the source for this page, you'll see that it's a nested loop where's he's filling an array of listboxes and he's not used < to represent the left angle bracket so we're seeing mangled source.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
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!
|
|
|
|