|
Hi,
I have two dialog boxes, the first one is a normal one with the default buttons ok and cancel, while the second has a ok and a combobox.
The program is supposed to work like this.
When a person clicks ok in the first dialog box, the program takes the "DEFAULT" values and does some job . if cancel is clicked, the second dialog box is opened and some data is chosen from the combobox and takes this value and does the same job.
when the job is done the application is closed,
Now when I open the application once again, I want the last chosen value from the combobox to be set as the "DEFAULT" values . Is there a specific way to do this..
Can anyone suggest me ways as to how to proceed..
Thanks.
Deepak Samuel
|
|
|
|
|
Get the selected item # of the combobox and save it in the registry using AfxGetApp()->WriteProfileInt(). Get it back using AfxGetApp()->GetProfileInt().
John
|
|
|
|
|
Look up history combo here at code project.. Should be in the combo & list box section.. It will do what you want..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Thanks for reminding me of that. I remember that is a good implementation so better not reinvent the wheel...
John
|
|
|
|
|
Does anyone out there have experience with job objects??? The JOB_OBJECT_PROCESS_ID_LIST structure (which contains (namely) the PID's for all processes running in a job) will only give me the PID for the first process that I assign to the job. (i.e. if I assign Processes with PID's 1132, 1322, and 898, the only PID in the structures member "ProcessIdList" is 1132). If anyone has any insight on this poorly documented subject I would be eccstatic. TIA
|
|
|
|
|
Hay im havin a problem trying to scan if my server is up using winsock because i cant scan the specific port is being used....
anyone know how i could do this?
thanks
|
|
|
|
|
Why is the size of an object of an empty class 1??
class Empty
{
};
void main()
{
Empty ob;
cout << sizeof(ob); //prints 1
}
Any idea why it should print 1? It cannot be the address of something because one byte is not sufficient to store a valid address in WIN32.
|
|
|
|
|
Check this out:
http://www.research.att.com/~bs/bs_faq2.html#sizeof-empty
|
|
|
|
|
According to Bjarne Stroustrup's
"To ensure that the addresses of two different objects will be different. "
However I'm not convinced. One byte is not enough to store any kind of address!!!
Anyway thanks David.
|
|
|
|
|
Yeah, I'm sure Dr. Stroustrup missed that action item. Anyway, don't confuse the size of an item with the size of its address. The size of the class is 1 byte, but it's address is still 4 bytes.
|
|
|
|
|
As others pointed out, the size of empty class objects is not zero so that pointers pointing to different objects do not have the same address value. Your confusion arises from asuming that the object somehow stores its own address: it doesn't, it is the pointers that store the address to the piece of memory occupied by the object (typically one byte). If you don't see it yet, consider the case of char s and pointers to char .
On a sidenote, there's an optional feature called empty base optimization by which an empty class object can effectively occupy zero bytes when it acts as a base of another class. Consider:
struct A{};
struct B{char m;};
struct C:public A{char m;}; Class C can be applied this optimization so that, so to say, its A base takes no space. This can be done as the space occupied by C itself (not taking into account A ) serves as the "token" byte where pointers to A can be set to.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you Joaquín for taking the time to explain it to me. It's now become clear to me. Essentially the address of every object of a class (whether empty or containing members) should be unique.
Regards,
Melwyn
|
|
|
|
|
I have a CListCtrl that I use for logging. For every item that is inserted (always at the back/bottom) I call EnsureVisible() . The annoying thing is, when I try to scroll to an older entry, the list control jumps to the new entry being inserted (ofcourse).
What I would like to do is implement the behaviour of the visual studio output window, i.e. only jump to the latest entry when the vertical scrollbar is set to it's max. (bottom) position. However, when I try something like this:
if (GetScrollPos(SB_VERT) == GetScrollLimit(SB_VERT) -1)<br />
{<br />
EnsureVisible(GetItemCount() - 1, TRUE);<br />
SetScrollPos(SB_VERT, GetScrollLimit(SB_VERT) -1);<br />
}
the cursor of the scrollbar keeps jumping up and down.
Anyone know how to do this the right way?
|
|
|
|
|
Hi!
If I use some "normal" MFC class, VisualStudio offers
such a nice name completition (inteli sense?!)
but with the gdi+ classes, the IDE dont show me the
hints, which methods a class has.
anybody an idea, how to enable it?
|
|
|
|
|
Intellisense in VisualStudio(6) is more or less broken, particularly when you are using third party libraries, you can get away with tools like Visual Assist.
Check out http://www.wholetomato.com
I think they have a 30 day trial.
Cheers,
Kannan
|
|
|
|
|
Ok, this is going to be confusing to explain, but simple to fix (me thinks).
I have a dialog box that pops up asking a user for a password. if they enter the icorrect password, another box pops up saying "Retry or Cancel". when the user hits Retry, i want it to start over (ie pop the password dialog box back up.)
Here's the code:
///*in PropsView.cpp*///
<br />
void CPropsView::OnWindowTransducers()<br />
{<br />
m_password.DoModal();<br />
bool bleh = g_password;<br />
if(bleh == TRUE)<br />
{<br />
m_chsheet.DoModal();
}<br />
else<br />
{<br />
m_fail_pass.DoModal();
m_password.DestroyWindow();<br />
}<br />
g_password = FALSE;<br />
}<br />
in another cpp file, I have an OnOk() statement if the user hits "retry". But, since that onok is in another cpp file, i can't do m_fail_pass.DestroyWindow() to close the retry/cancel window, and i dont know how to make the loop start at the top again with the Password Dialog.
Does anyone get what i mean?
*.*
cin >> knowledge;
|
|
|
|
|
Do not dismiss the password box until the correct password has been entered, or until a certain number of failures has been met.
For a modal dialog, there is no need to call DestroyWindow() . When DoModal() returns, the window is gone.
void CPropsView::OnWindowTransducers()
{
CMyPasswordDlg dlg;
if (dlg.DoModal() == IDOK)
{
AfxMessageBox("Correct password was entered.");
m_bPassword = true;
}
else
{
AfxMessageBox("Correct password was not entered.");
m_bPassword = false;
}
}
void CMyPasswordDlg::OnOK()
{
CString str;
m_pwd.GetWindowText(str);
if (str == "password")
CDialog::OnOK();
else
{
AfxMessageBox("Incorrect. Try again.");
m_pwd.SetFocus();
m_tries++
}
}
|
|
|
|
|
i didn't know what to define m_pwd as, so i defined it as CMyPasswordDlg m_pwd in the okok() function, and that gives a debug error when i hit ok.
*.*
cin >> knowledge;
|
|
|
|
|
m_pwd is an edit control. Note the use of GetWindowText() !! What is the "okok" function? Define "debug error."
|
|
|
|
|
oops. okok = OnOk() but i mistyped it.
I changed m_pwd with my edit control variable, and now when i compile, i get these errors:
error C2039: 'GetWindowTextA' : is not a member of 'ATL::CStringT<basetype,stringtraits>'
with
[
BaseType=char,
StringTraits=StrTraitMFC_DLL<char>
]
hmm, was m_pwd supposed to me a "Control" variable or a "value" variable when i created it witht he add variable wizzard? i made it a value, so its a CString, not a CEdit.
[Edit]
~it works! that was it. thanks a whole whole whole lot!
*.*
cin >> knowledge;
|
|
|
|
|
keegan wrote:
hmm, was m_pwd supposed to me a "Control" variable or a "value" variable when i created it witht he add variable wizzard? i made it a value, so its a CString, not a CEdit.
It is a "control" variable. You would not be able to use GetWindowText() on a "value" variable.
|
|
|
|
|
just figured that out, once again you saved me from the horrors of MFC. thanks.
*.*
cin >> knowledge;
|
|
|
|
|
It should not make a difference that something is in another cpp file if your variable vaild in the scope that you need to use it.
The way I do this is in your OnOK dialog for the password entry you do the required password varification and create the second dialog if necissary. As a result of the second dialog you either exit the first dialog by calling the base class CDialog::OnOK() or continue by not calling it.
John
|
|
|
|
|
well, i would make the dialog i need top be created if the password is correct (m_sh), but the only place i can call
m_sh.DoModal()
is in PropsView.cpp, and the onok() is in property.cpp. If, in Property.cpp, i try to include PropsView.h, where m_sh is defined, i get a whole lotta errors. so, as far as i can figure out i have to create the new dialog in PropsView.cpp, and do the authentication of the password there.
grr.
*.*
cin >> knowledge;
|
|
|
|
|
when I use string ,I can write
m_StringeditBox.GetWindowText (str);
if(str.IsEmpty()){
MessageBox("please,choose one of them ! ");
return;
}
like tihs !
if I use edit box for numeric value how can I warn ?
emroz
|
|
|
|