|
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 ?
|
|
|
|
|
yes it is...
use it as shown by mike...it will do the rest..
cheers
Himanshu
|
|
|
|
|
In my VC++ MDI application ,The ini(configuration file) file that i'm maintaining is very huge.When i try to extract strings from it using GetPrivateProfileString function,The function is unable to retrieve the values stored after certain part of the file.I'm facing this problem only in Windows 98 and there is no problem in Windows 2000.Any suggestions
|
|
|
|
|
|
Thanks a lot for your suggestion.If i open the ini file as a flat file ,read each line and store it into CMapStringToString object,does MFC puts any restriction on the size of this map(in memory size or number of strings it can hold)
|
|
|
|