|
How I click the button and then it will open the program @ file. Example: Window Explorer, Microsoft Work....
|
|
|
|
|
Best Friend wrote:
button
What button? Your button, my button, everyone's button?
Best Friend wrote:
program @ file
What's program @ file? Is this a new computer term I've yet to grasp?
---
Your question is not quite coherent, my Best Friend, but are you by any chance
talking about using the ::ShellExecute() API to launch the windows program associated with the given filename?
If so then your question has been answered.
I Dream of Absolute Zero
|
|
|
|
|
Hi guys,
I have just learned how to create a dialog-based application with mutiple child dialogs. So far it works fine, however, in Debug window, I always received memory leak warning upon the app exit :
Detected memory leaks!
Dumping objects ->
childdlg.cpp ........
I am just wondering what could cause this?
Basically, say, I have a parent dialog class, say CMyDlg and a child dialog class called CChildDlg. The child class was included on the top of MyDlg.cpp file
#include <ChildDlg.h>
CChildDlg *vChildDlg;
I embedded the child dialog into parent by putting the following codes in OnInitDialog() of the parent's cpp file, MyDlg.cpp.
vChildDlg = CChildDlg();
vChildDlg->Create(IDD_CHILD_DIALOG, this);
vChildDlg->SetWindowPos(this, 20, 20, 50, 50);
vChildDlg->ShowWindow(SW_SHOW);
That looks pretty straight forward. But why on the app's exit, it causes memory leak? Is there something I need to do perhaps in the parent and child class' destructor?
Thanks
|
|
|
|
|
the line
vChildDlg = CChildDlg();
creates an instance of CChildDlg.
You need to delete this instance of vChildDlg when the app exits.
|
|
|
|
|
Thank you guys.
I realise I originally placed "delete vChildDlg" in the parent's destructor, which however, was never called. Because the program exit with exit() associated to the exit button in the child dialog.
|
|
|
|
|
Don't you use new without delete ?
"Gods die, when their believers are gone." --from Sandman by Neil Gaiman
|
|
|
|
|
hi,
i want to know how to get the message after window has been shown. i have checked out with OnShowWindow, WindowPosChanged ... seems that all can report me the Window is about to be shown. that's not ok... as i want to do sth after the window already being seen by the user.
any help?
thanks,
jim
|
|
|
|
|
OnDestroy()
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
hi..
void CEditorView::OnInitialUpdate()<br />
{<br />
CScrollView::OnInitialUpdate();<br />
<br />
SetScrollSizes(MM_LOENGLISH, CSize(2020, 1020));<br />
}<br />
in the above code..i wanna know when i set the mapping mode to MM_LOENGLISH, the param that i supply...are they depicted in mapping mode as i entered??or are they changed to mapping mode params and then entered??
for eg..above is the mapping mode taken in, is it exacly 2020 and 1020 in MM_LOENGLISH???
or is it converted to LOENGLISH and the value has changed to LOENGLISH and is no longer 2020 by 1020???
i gues its a more of my understanding prob...can someone pls help???tks....
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
hi...i am facing a small prob..
void CEditorView::OnDraw(CDC* pDC)<br />
{<br />
CEditorDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
<br />
pDC->SetMapMode(MM_LOENGLISH);<br />
<br />
CPoint pos;<br />
pos.x = pDoc->GetGridWidth()*100;<br />
pos.y = pDoc->GetGridHeight();<br />
pDC->DPtoLP(&pos);<br />
<br />
CRect rect(10, -10, 2000, -1000);<br />
pDC->Rectangle(rect);
when i do this
CRect rect(10, -10, pos.x, pos.y);
the rectangle that is drawn isboundless...i.e no mater how long i put the scroll bars..i still cant see the end of therect..wherea as if i do this
CRect rect(10, -10, 2000, 1000);
i can see the rectangle...
why is that???why cant i see the rect when iuse the first method??
tks for any help...
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Hi, all
I want to make wrapper member function
like this,
class A
{
int Xsprintf (char * pszDest,const char * pszFormat, ...)
{
// this might not right, but I want like this...
sprintf( pszDest, pszFormat, ... );
}
};
How do I can this?
thanks!
|
|
|
|
|
Only way to avoid using va-arg, is to avoid variable number of arguments.
If you have some specific setups, you could say
XSprintf(char * output, char * format, int I1, int I2){
sprintf(output, format, I1, I2);
}
and
XSprintf(char * output, char * format, int I1, int I2, int I3){
sprintf(output, format, I1, I2, I3);
}
but this is not very flexible. For every kind of argument, you need new Xsprintf definition. May be good enough, tho.
|
|
|
|
|
Create an ovcerload for sprintf in your project.
In stdio.h sprintf has only one prototype so
int CYourAppSDI::sprintf(CString str)
{
}
would work or
int CYourAppSDI::sprintf(int nVar)
{
}
would work or
int CYourAppSDI::sprintf(CString str,int nVar)
{
}
would work right?
Now their are some good replacements for sprintf on this site and others.
So all you have to do is write or copy the code inside your overload.
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
This was talked about (unsuccessfully) here.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Review your design constraints. By excluding the use of va_arg, you are making the problem very hard if not impossible (excluding the use of hacks and kludges).
Don't shoot yourself in the foot by using silly design constraints.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi All,
Does anyone know why I would get a first chance exception occur when I try to get the current Username in a COM object I have? the error message is as follows:
First-chance exception in app.exe (SECUR32.DLL): 0xC0000005: Access Violation.
The program 'C:\app.exe' has exited with code 0 (0x0).
when all I am trying to do is
LPTSTR username;
DWORD cchBuff = 1024;
BOOL result = GetUserName(username, &cchBuff);
thanks for your help
cheers
Bryce
|
|
|
|
|
|
Hi Michael,
Thanks, you are indeed correct.
below is what is needed to be done:
<br />
LPTSTR username;<br />
DWORD cchBuff = 1024;<br />
TCHAR tchBuffer[1024]; <br />
<br />
username = tchBuffer;
BOOL result = GetUserName(username, &cchBuff);<br />
cheers
Bryce
|
|
|
|
|
#define MAX_LEN 255
CString str;
char ch[MAX_LEN];
DWORD dwNameSize = MAX_LEN;
GetUserName(ch, &dwNameSize);
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Hi Guys
I have made my custom resizable combo box. I want to display a gripper in top right corner but windows don't has any in built style for that.
Can anyone guide me how to bring a gripper in top right corner.
can we rotate it some how using the funtion : SetWorldTransform
or is there some other possible way out
|
|
|
|
|
First of all I am new to C++ and in particular MFC, but I am making some minor changes to a project that I downloaded from here and the final change I need to make is to ask the user a question right after the dialog has loaded. In Visual FoxPro I would put this in the Activate of the Dialog, but in MFC this causes a multitude of issues such as:
1. The dialog doesn't actually display, so there is just a MessageBox in the middle of the screen. - The dialog displays after I click OK on the message which is understandable.
2. The Activate runs many times while the dialog is loading which causes any code I put in there to run many times (I put a flag in there to make it run only once.)
My OnActivate is shown bellow:
<br />
afx_msg void CdotNetInstallerDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimised)<br />
{<br />
CDialog::OnActivate(nState, pWndOther, bMinimised);<br />
<br />
if (m_bRunFromReboot)<br />
{<br />
m_bRunFromReboot = false;<br />
if (MessageBox("Continue with installation?", "Requirements Checker", MB_YESNO | MB_ICONQUESTION) == IDYES)<br />
ResumeInstall();<br />
}<br />
return;<br />
}<br />
Can somebody please tell me where I should put this code? I have figured that putting it in OnActivate is probably wrong.
Thanks,
Chris Ormerod
|
|
|
|
|
Thanks to GeMe_Hendrix about 10 posts below this one I have the answer (I should look before I post):
Try creating your own custom message ad handler for it first therefore at the top of your dialog CPP file...
#define WM_MYOWNMESSAGE WM_USER + 1001;
... Then in the header file put...
afx_msg LRESULT OnMyOwnMessage(WPARAM wParam, LPARAM lParam);
...Then the appropriate body for it...
LRESULT CMyDialog::OnMyOwnMessage(WPARAM wParam, LPARAM lParam)
{
... Show the file dialog box (I know it has to be modal)
return 0;
};
... And finally in the body put...
ON_MESSAGE(WM_MYOWNMESSAGE, OnMyOwnMessage)
... in the BEGIN_MESSAGE_MAP section...
... To call the message handler put this in the OnInitDialog function just before it returns...
PostMessage(WM_MYOWNMESSAGE, 0, 0);
And as a bonus I got an explanation of the message queue.
Chris.
|
|
|
|
|
Hi All,
I have a question on the following code.
class ClassA<br />
{<br />
virtual void TestA()=0;<br />
};<br />
<br />
class ClassB: public ClassA<br />
{<br />
virtual void TestA();<br />
ClassB();<br />
virtual ~ClassB();<br />
void PrintB();<br />
};<br />
<br />
void ClassB::TestA()<br />
{<br />
cout << "TestA is Called from ClassB"<<endl;<br />
return;<br />
}<br />
<br />
void ClassB::PrintB()<br />
{<br />
cout << "PrintB is called" << endl;<br />
return;<br />
}<br />
<br />
class ClassC: public ClassA<br />
{<br />
virtual void TestA();<br />
ClassC();<br />
virtual ~ClassC();<br />
void PrintC();<br />
};<br />
<br />
void ClassC::TestA()<br />
{<br />
cout << "TestA is Called from ClassC" << endl;<br />
return;<br />
}<br />
<br />
void ClassC::PrintC()<br />
{<br />
cout << "PrintC is called" << endl;<br />
return;<br />
}<br />
<br />
ClassA *pB;<br />
ClassA *pC;<br />
<br />
pB = new ClassB();<br />
pC = new ClassC();<br />
<br />
pB->TestA();
pC->TestC();
<br />
pB->PrintB();<br />
pC->PrintC();
In the above code, I am getting compilation errors as commented in the code. Is there anyway of calling methods of inherited class with a pointer to the base class?
My requirement is to call appropriate inherited class at runtime basing upon the user input with a single pointer to a base class. i.e
ClassA *pGeneric;<br />
if(user_input == 1)<br />
pGeneric = new ClassB()<br />
else<br />
pGeneric = new ClassC();
This works when the both inherited classes have the same methods but fails if inherited class an extra method. Is there any way to call one of the inherited classes during runtime with a SINGLE pointer to base class?
First of all, I want to know is it possible to do in C++? If it is possible, please suggest me the approach to take.
Please help me out. Please suggest me any other methods that provide the same functionality.
Thanks in Advance,
Anil
|
|
|
|
|
you can use dynamic_cast to see if the class is indeed of a particular derived type, then cast it to make the call. If you want the functionality to be available from a base class instance, the method needs to be in the base class.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Chris, Thank you for your email. Could you please tell me how to declare the pointer variable for dynamic cast?
Thanks,
Anil
|
|
|
|
|