|
thanks for reply.
i make this:
CDialogA:
int global_int;<br />
...<br />
<br />
void CDialogA::OnOk()<br />
{<br />
...<br />
global_int=5;<br />
...<br />
}
CDialogB:
extern int global_int;<br />
...<br />
void CDialogB::OnQuestion()<br />
{<br />
...<br />
int number=global_int;<br />
...<br />
}
but the number has not the same "content" as global_int in CDialogA. why?
can you help me?
sunny
|
|
|
|
|
What is the order of execution? CDialogA::OnOK() before CDialogB::OnQuestion() ? To sort it out, declare the variable and assign it a dummy value (may be zero), then check if number is zero or five.
|
|
|
|
|
oooohhhhhhhhh.....i know what´s wrong!!! thank you very very much....
João Paulo Figueira wrote:
What is the order of execution?
this was the point. i created a dialog at the beginning of my program and hide it and later i show it (inside this dialog was the problem). And so the order of execution was wrong!!!!!
thank you very very much.
sunny
|
|
|
|
|
How about this:
(a)
/// declaration
int iMyGlobalInteger = <whatever_suits_you>;
(b)
/// reference:
extern int iMyGlobalInteger;
(c) Reconsider all the above and change your plan. Global variables are evil. Whenever you have a global variable, you have a design flaw.
(d) Reconsider all the above. Whenever you don't know how to implement a global variable, you have a severe C language knowledge problem. This is very basic knowledge, if you don't mind me being frank. Stop whatever programming you're at right now. Stop it immediately. Go out, buy and read a good book on C/C++, then return to the design of the tool (see (c), above).
Bernd
|
|
|
|
|
thanks for reply.
i make it in the same way (a) and (b).
CDialogA:
<br />
int global_int;<br />
...<br />
<br />
void CDialogA::OnOk()<br />
{<br />
...<br />
global_int=5;<br />
...<br />
}
CDialogB:
<br />
extern int global_int;<br />
...<br />
void CDialogB::OnQuestion()<br />
{<br />
...<br />
int number=global_int;<br />
...<br />
}
but the number has not the same "content" as global_int in CDialogA. why?
that´s why i asked. can you help me?
sunny
|
|
|
|
|
Your code snippet doesn't indicate an error; I assume this is because you've reduced it too far for display in this thread.
Alternatively, you might be looking into the data at the wrong times? After all, CDialogA would only set the variable to 5 in its OnOk() handler; your snippet doesn't indicate when CDialogB::OnQuestion() occurs with relation to CDialogA::OnOk().
I can only repeat (c): global variables are evil and, with very rare exceptions, a good indicator for poor design.
Class A needs to communicate with class B? Send a message from A to B.
Any class needs to communicate with any other class? Implement a controller class as a central communications hub (see: singleton design pattern).
Any class needs to communicate with anything else in a haywired fashion in a way a singleton controller cannot resolve with elegance? Re-visit your design. Haywire comms is a bad sign, and a good indicator for poor design.
Bernd
|
|
|
|
|
You can do it in several ways:
1.
Declare it in a header file included in all the classes you need.
2.
Declare it in a cpp file and outside the class scope, and then try to reach it with the "extern" keyword.
3.
My favourite one:
In the Application object (typically "TheApp"), declare it inside the class that defines the application, and then reach the application object... (you can be almost sure that you'll be able to reach the header file that contains the application from every header or implementation file in your project.
MoreOver I would declare the variable as private and give the SET/GET interface functions in order to access it (in order to be more standard and to be able to check what is happening always and easily)...
Sample:
header file of the application
class CTCCApp : public CWinApp
{
public:
CTCCApp();
...
private:
int theIntegerVarToBeAccessed;
public:
int GetTheIntegerValue();
void SetTheIntegerValue(int iValue);
implementation file of the application
void CTCCApp::SetTheIntegerValue(int iValue)
{
theIntegerVarToBeAccessed = iValue;
}
int CTCCApp::GetIntegerValue()
{
return theIntegerVarToBeAccessed;
}
OK, now it's time to get access to those functions from everywhere you need...
Where you need to access that integer (let's say WHERE.cpp)
/*---------------------------------------------
COMMENTS FIRST
Be sure that you have a #include "TCCApp.h"; in your header or in your implementation file.
---------------------------------------------*/
//Inside the function where you want to access that:
extern CTCCApp TCCApp;
// Now you can get:
TCCApp.GetIntegerValue();
TCCApp.SetIntegerValue(10);
I think that this is the best method because you can "share" a lot of datatypes (even pointers to...) and you can make it in a safe and sorted way...
Hope this helps...
|
|
|
|
|
Does anybody have any experience of doing application integrated MailMerging in Openoffice.
I am looking produce an application to merge data into docs from a database, this project will be coded in various different languages (C++, C#, Java, etc)
Unfortunatly there doesnt seem to be any decent documentation with the OpenOffice SDK and google doesnt return much joy either
Regards
MR
|
|
|
|
|
OpenOffice? That crappy imitation of MS Office?
Well, you have the sources.
Good luck!
* you will need it *
I see dumb people
|
|
|
|
|
Ours is not to reason why......
Ours is just to do what da boss man says
|
|
|
|
|
Hi everyone. I have a dialog with a propertysheet with a tab control style. The propertysheet has 5 propertypages, all of the same class. I want each tab to have a different title on it, eg. "One", "Two", etc. Since they are all of the same class, I can't set the title statically. In the propertypage's OnInitDialog() I try to set the title, but it won't change the title on the tab. Is there a way to set the tab titles in the propertypage's OnInitDialog()? I could create 5 different dialog classes for each propertypage and could set the title statically, but that would be wasteful. I use the code below. It doesn't set the title. It also crashes when the program is in release mode, which I can't understand. Thanks for any help!
<br />
BOOL CDlgMyDialog::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
<br />
<br />
for(i = 0; i < 5; ++i)<br />
{<br />
m_ppgMyPropPages[i].SetMode(i);<br />
m_ppsMyPropSheet.AddPage(&m_ppgMyPropPage[i]);<br />
}<br />
<br />
m_ppsMyPropSheet.Create(this, WS_CHILD | WS_VISIBLE, 0);<br />
m_ppsMyPropSheet.ModifyStyleEx(0, WS_EX_CONTROLPARENT);<br />
m_ppsMyPropSheet.ModifyStyle(0, WS_TABSTOP);<br />
<br />
CRect rcSheet;<br />
GetDlgItem(IDC_PPS_MAIN)->GetWindowRect(&rcSheet);<br />
ScreenToClient(&rcSheet);<br />
m_ppsMyPropSheet.SetWindowPos(NULL, rcSheet.left- 7, rcSheet.top - 7, 0, 0,<br />
SWP_NOZORDER | SWP_NOSIZE);<br />
<br />
}<br />
<br />
BOOL CPpgMyPropPage::OnInitDialog() <br />
{<br />
CPropertyPage::OnInitDialog();<br />
<br />
if(m_iMode == 0)<br />
SetWindowText("One");<br />
if(m_iMode == 1)<br />
SetWindowText("Two");<br />
if(m_iMode == 2)<br />
SetWindowText("Three");<br />
if(m_iMode == 3)<br />
SetWindowText.SetWindowText("Four");<br />
if(m_iMode == 4)<br />
SetWindowText.SetWindowText("Five");<br />
<br />
<br />
}<br />
|
|
|
|
|
Take a look at this...
in the Constructor of the property sheet...
this->AddPage(&this->m_PPDlgParametritzacioDirectaEixos);
this->m_PPDlgParametritzacioDirectaEixos.m_psp.dwFlags |= PSP_USETITLE;
this->m_PPDlgParametritzacioDirectaEixos.m_psp.pszTitle = "Ejes";
Hope this helps...
|
|
|
|
|
Just Have a Look at the
http://www.codeguru.com/forum/printthread.php?threadid=224993
|
|
|
|
|
Hi.
I just saw this cool application. I was wondering how do they acheive such a page flipping.
Do they use SetWindowRgn to change the skin of application. But even if they do that how is it so fast.
This is the URL of a sample they have. Cool han!
http://digitalpageauthor.com/download/ToshibaDPA.exe [^]
-----------------------------
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Oh, yes! Very good idea!
I'm sure that this is not a virus not a trojan:
Let's run the dependency viewer:
Hmmm... Your "page flipping" code seems to be importing functions from several "fun" DLLs, the funnier being:
1. Wininet
2. Winsock
Not to mention it uses LoadLibrary and GetProcAddress.
It calls ADVAPI, so it may be messing with my registry.
Sure, I will run it. I trust you entirely.
I see dumb people
|
|
|
|
|
How to do drag and drop of a file into a simple window ?
|
|
|
|
|
|
the old method run correctly and drag and drop work fine;
but only if i set with the wizard "Accept Drag file".
At run time , with the istruction myWindow.DragAcceptFile(TRUE);
do not work and return the error:
''Debuf assertion failed. Program drag.exe , File : wincore.cpp, line 3836''
at line of this istruction
|
|
|
|
|
How to run default mail client USING API ? Thanks !
|
|
|
|
|
ShellExecute ( hwndYourWindow, _T("open"), _T("mailto:user@hostname.com"),
NULL, NULL, SW_SHOWNORMAL );
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
i want only to open the program (no send message)
can I use API ?
|
|
|
|
|
ya u can use this api..this will just open the default mail client..as mike has suggested..
cheers
Himanshu
|
|
|
|
|
i tryed this method but it only open the window to send email;
i want to open the entire software (the main window) as Outlook or NetscapeMessenger or Opera (the default...)
exist an api to do this ?
Thanks
|
|
|
|
|
use shellexecute...look for it in msdn and provide it with few parameters..I guess it just uses mail to: email@email.com like something..to open a default mail client..
cheers
Himanshu
|
|
|
|
|
excuse for my reply, I am not an expert.
but the is an API the shellExecute ?
|
|
|
|