|
Ryuk1990 wrote: How would you set up a member variable for a button?
For check-boxes, right-click on the control and select 'Add variable' in the context menu. Make sure the 'Control variable' box is unchecked.
The procedure for radio buttons is slightly different - see the MSDN page[^].
It seems you now have to add DDX_whatever calls into your dialog's DoDataExchange method for value variables (which is a pain in the behind - I though Visual Studio did it for you), so here are some examples:
DDX_Check(pDX, IDC_CHECK1, c1);
DDX_Radio(pDX, IDC_RADIO1, values);
DDX_Text(pDX, IDC_EDIT1, edit);
DDX_Text(pDX, IDC_RICHEDIT21, rich);
Now, for the calculate button - for buttons like that, you add an 'OnClicked' method. The easiest way to do that is to double-click on the button in the MFC dialog editor - Visual Studio will add the handler automatically.
In the handler, the first thing to do is to call UpdateData(TRUE), to get the values of controls into your member variables. Now you can calculate a string holding your summary information, assign to to the string variable associated with your edit box and finally call UpdateData(FALSE) to push the string value into the member variable values into the controls:
void CMyDialog::OnBnClickedCalculate()
{
UpdateData(TRUE);
m_summaryValue = m_firstName + " " + m_secondName + ", " + m_address + whatever else you want;
UpdateData(FALSE);
}
Hope that helps!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'll look into that, thanks.
By the way, do you know how to delete previous member variables that I created? I don't think I set up my MV's for check boxes correctly.
|
|
|
|
|
Ryuk1990 wrote: By the way, do you know how to delete previous member variables that I created?
Remove their declarations and all references to them from the dialog's .cpp and .h files with the text editor. The 'Find All References' command (right-click on the variable in the text-editor) is useful for that (if you can't see that menu command, it's possible it's VS2008 only - I don't have VS2005 installed).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Ryuk1990 wrote: Can anyone help? Does anyone maybe know of any free tutorials on dialog-based stores?
what about 'Scribble'. It's free with the Compiler.
Bram van Kampen
|
|
|
|
|
Any ideas how I could implement something like this:
void a_main() { ; }
#define b(fn) a##fn()
int main()
{
b(__FUNCTION__);
return 0;
} Hope you get the idea, since I'm not good at explaining. Anyway, the point is to have the preprocessor to generate the function name for you, or something similar.
Thanks!
EDIT: Oh yeh, obliviously this doesn't work, because preprosessor isn't processing __FUNCTION__ to a umm.. usable text, instead the preprosessor will process it later to a string.
|
|
|
|
|
As you've found, you can't use __FUNCTION__, as it's inserted as a string, not a token. This is a shame, because you can convert a token to a string in the pre-processor, but not vice-versa.
So, you're only option would be this:
void a_main() { ; }
#define b(fn) a##fn()
int main()
{
b(main);
return 0;
}
i.e. putting the function name in explicitly
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Yeps, that's how I'm doing it ATM. I just thought that I'd ask if anyone knew a trick I don't. Many thanks!
|
|
|
|
|
Scenario: The application has 10 nodes connected in a network. each node can either act as server/client. At any given time there will be only one server and one client.
My question is say for example if default server is down - then client application will poll the message to remaining nodes looking for server if not it will become server for remaining clients.
So, how to poll message in a network using MFC.
|
|
|
|
|
You can use UDP broadcasting technique in that situation.
Server should implements workerthread which calls UDP recvfrom and client calls UDP sendto when its default server is down.
Notice; UDP broadcasting would not pass through the routers to different network, so machine nodes should be in the same network usually.
|
|
|
|
|
|
How to connect database.database is in exelsheet.
|
|
|
|
|
So which is it: reading from a database or an Excel file? You can use ODBC for both.
You can also use Excel Automation for the latter.
Are you using MFC?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am using MFC. hw to connect exelsheet as database while doing MFC project.
|
|
|
|
|
Supriyanka wrote: hw to connect exelsheet as database while doing MFC project.
Have you tried ODBC with CRecordset and CDatabase ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
Which Database are you connect?
you can used AdoConnect
_ConnectionPtr * con;
_RecordsetPtr * rec;
|
|
|
|
|
Thanks for your answer but it was not my question!
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi , How does following code works.
int s = 0 ;
printf("%d" ,s["123456789"]); //Output 49
printf("%d",s["987654321"]); //Output 57
printf("%d",s["9"]); //Output 57
Please provide any comments on this...
|
|
|
|
|
The "so-called" code is returning the ASCII base-10 value of the first character in the string.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
There's a couple of factors at play here:
- Array accessing -
array[index] can be rewritten as index[array] (it's all because of the syntax of PDP-11 assembly language, in which and for which the first C compiler was written). So, with s==0,
- s["123456789"] == "123456789"[s] == "123456789"[0] == "1" == 49 (ASCII code)
- s["987654321"] == "987654321"[s] == "987654321"[0] == "9" == 57 (ASCII code)
- s["9"] == "9"[s] == "9"[0] == "9" == 57 (ASCII code)
- When you use the format string "%d", printf interprets the next argument on the stack as an integer. Items on the stack are aligned on 4-byte boundaries, so characters can be read as integers, which means that the ASCII code of the character is printed (so long as the character is zer-extended before it's pushed onto the stack).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: Array accessing - array[index] can be rewritten as index[array]
Yeah, read that somewhere recently. interesting.
Thanks.
This signature was proudly tested on animals.
|
|
|
|
|
Holy Moly!
How do you know stuff like this?! I'm duly impressed.
If the post was helpful, please vote!
Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ
Now and forever, defiant to the end.
What is Multiple Sclerosis[ ^]?
|
|
|
|
|
Mustafa Ismail Mustafa wrote: How do you know stuff like this?!
20 years of reading stuff combined with a (very) good memory You may have had an annoying classmate at school who never seemed to have to study for exams? Yeah, that was me - learning stuff just sticks with me.
Remembering peoples names or what I was doing last week? Nah, can't do that!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: You may have had an annoying classmate at school who never seemed to have to study for exams?
Funny, its like you were describing me. I never took that in class though (the OP that is)
If the post was helpful, please vote!
Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ
Now and forever, defiant to the end.
What is Multiple Sclerosis[ ^]?
|
|
|
|
|
Hi!
I'm having a problem placing a transparent window over a window of a foreign application. Description:
1. I create a transparent window with controls on it(Transparency color = RGB 255,0,255)
2. I'm searching, finding a window of a foreign application and set my window on it (via SetWindowPos(Foreignwindow, Mywindow)). it works.
3. If the foreign window is minimized, my window has to minize, too. After maximize...my window should maximize, too, but the order of the windows should be the same....my window over the other
4.If the user opens another window e.g. Notepad and Notepad is topwindow...my window should be visible, to as long as the foreign window is opened but the ordering should last. So notepad is at top, my window is the next and the foreign window.
Example:
-Foreign Window, above...
-Mytransparent window
Notepad opened...
-Foreign Window, above...
-Mytransparent window, above...
-Notepad
My transparent should always positioned over the window and always visible if the foreign window is visible. If the foreign window is not visible, my transparent window shouldn't be visible, too.
How to do it? someone has an idea or code?
Thank you very much and excuse my bad english.
|
|
|
|