|
but how to call the sub form.. i having problem with calling the sub form.
Thank you.
|
|
|
|
|
Have look at the following discussion from a few days ago:
http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2898321[^]
The actual question took a little decoding, but hopefully the answers will help you a bit!
They're based on MFC's CDialog, but hopefully the approach will help you.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
i am facing a new problem now...
void Spartamenu::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
//OnCancel();
}
even after i disable the onCancel and run it. when i click on the button its still closing the application.
________________________________________________________________________
void Spartamenu::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CDialog::SetTimer(IDD_AUTO,1,NULL);
}
for open a subform i use this command but when i click on it nuthing happen...
i am so confused.. kidly help me plz ya..
|
|
|
|
|
OnCancel and OnOK are slightly special - other commands need to be in the message map, but not for IDOK / IDCANCEL.
If you look in the documentation for CDialog::OnCancel, you'll see that it is a virtual method.
So, override OnCancel, and make it do nothing.
ie:
void SpartaMenu::OnCancel ()
{
}
I do this for my modeless dialogs - in fact I have an overriden base class for them all (CModelessDialog ) that does this, so I don't have to remember each time.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
ok.. so hows i should call the other form..
Below is the coding for the first form and second form.. i need to call the form 2 from this form when i click Button1. help me plz...
______________________________________________________________________
Form 1
// Spartamenu.cpp : implementation file
//
#include "stdafx.h"
#include "Sparta.h"
#include "Spartamenu.h"
IMPLEMENT_DYNAMIC(Spartamenu, CDialog)
Spartamenu::Spartamenu(CWnd* pParent /*=NULL*/)
: CDialog(Spartamenu::IDD, pParent)
{
}
Spartamenu::~Spartamenu()
{
}
void Spartamenu::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Spartamenu, CDialog)
ON_BN_CLICKED(IDCANCEL, &Spartamenu::OnBnClickedCancel)
ON_BN_CLICKED(IDC_BUTTON1, &Spartamenu::OnBnClickedButton1)
END_MESSAGE_MAP()
void Spartamenu::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
OnCancel();
}
void Spartamenu::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CDialog::SetTimer(IDD_AUTO,1,NULL);
DestroyWindow();
}
____________________________________________________________________
Form2
// Auto.cpp : implementation file
//
#include "stdafx.h"
#include "Sparta.h"
#include "Auto.h"
// Auto dialog
IMPLEMENT_DYNAMIC(Auto, CDialog)
Auto::Auto(CWnd* pParent /*=NULL*/)
: CDialog(Auto::IDD, pParent)
{
}
Auto::~Auto()
{
}
void Auto::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Auto, CDialog)
ON_BN_CLICKED(IDCANCEL, &Auto::OnBnClickedCancel)
ON_BN_CLICKED(IDOK, &Auto::OnBnClickedOk)
ON_LBN_SELCHANGE(IDC_LIST1, &Auto::OnLbnSelchangeList1)
END_MESSAGE_MAP()
// Auto message handlers
int Auto::DoModal()
{
}
void Auto::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
OnCancel();
}
void Auto::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
OnOK();
}
void Auto::OnLbnSelchangeList1()
{
// TODO: Add your control notification handler code here
}
_____________________________________________________________________
|
|
|
|
|
Please read the other Q&A session I linked you to. I gave the answer to an identical question there. And it's too long to type again.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi all,
How can I know the number of lines of my file, and I want to read any perticular line ?
plz gv me solution..thx
|
|
|
|
|
There is no specific API for getting the number of lines in a file. you need to write your own code for that.
And what do u mean by saying "read a perticular line"?
|
|
|
|
|
ok...I meant, I want to read only 10 and 12 number lines from the file.
|
|
|
|
|
CStdioFile will be better to use... with that you can read line by line.
- ns ami -
|
|
|
|
|
As already suggested by ns ami, CStdioFile is a better choice, since it provides the ReadString [^] method (to read the file line by line).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
By using CStdioFile prob is solved....thnx a lot
|
|
|
|
|
Hi,
I want to append a line to file i tried like this:
CString strNewWord (_T(" Test line to write"));
CStdioFile file;
file.Open(strSystemPath,CFile::modeWrite|CFile::modeNoTruncate,NULL);
file.SeekToEnd();
CString strWriteData("\\n ");
strWriteData+=strNewWord;
file.WriteString(strWriteData);
file.Close();
this code appends data but in single line (assume no compile time errors):
\n Test line to write\n Test line to write\n Test line to write
I want like this:
Test line to write
Test line to write
Test line to write
|
|
|
|
|
Looking at the documentation[^](gasp), it says "Any newline character in lpsz is written to the file as a carriage return–linefeed pair".
I can never remember whether \n or \r is a newline character, and which is linefeed - so try either single stepping into the WriteString command and looking, or guess and try \r .
Good luck,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: I can never remember whether \n or \r is a newline character
On windows none of them (the sequence \r\n is newline), see, for instance http://en.wikipedia.org/wiki/Newline[^].
I suppose that 'any newline' means \r or \n or \r\n (but I didn't make a test).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
That's why I'd step in and get an authoriative answer! I don't trust me either.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Please don't trust me: from the same article:
To facilitate the creation of portable programs, programming languages provide some abstractions to deal with the different types of newline sequences used in different environments.
The C programming language provides the escape sequences '\n' (newline) and '\r' (carriage return). However, these are not required to be equivalent to the ASCII LF and CR control characters. The C standard only guarantees two things:
1. Each of these escape sequences maps to a unique implementation-defined number that can be stored in a single char value.
2. When writing a file in text mode, '\n' is transparently translated to the native newline sequence used by the system, which may be longer than one character. (Note that a C implementation is allowed not to store newline characters in files. For example, the lines of a text file could be stored as rows of a SQL table or as fixed-length records.) When reading in text mode, the native newline sequence is translated back to '\n'. In binary mode, the second mode of I/O supported by the C library, no translation is performed, and the internal representation of any escape sequence is output directly.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
crazy_sam wrote: CString strWriteData("\\n ");
....
\n Test line to write\n Test line to write\n Test line to write
Of course, it does exactly what you told it to do....
Hint: double backslashes.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi all,
In my vc++ application I am performing some operations using the Registry functionality but in Vista , registry virtualisation is coming in to picture and is creating the keys in virtual store instead of the path which i gave.I have gone through some of the material on this topic and found that if the user is not an admin then this will happen.But for my laptop I am holding the admin previlages then how come I am not able to create the keys in the correct location.
Thanks in Advance.....
|
|
|
|
|
In Vista, all programs run with low privileges by default even if the user has admin privileges. You have to elevate it to run with admin privilege by right clicking on the EXE and selecting "Run as Administrator".
«_Superman_»
|
|
|
|
|
Thats looks fine.
But how can I do that programtically coz when I deliver my product to the customer it has to be done implicitly, we can ask the user/customer to run in using the context menu(using right click)...
Do we have any other approach of doing this programatically?
|
|
|
|
|
You can specify the required privilege in the application manifest file which is an xml file.
Please check some documentation on how it is done.
«_Superman_»
|
|
|
|
|
|
Hi everyone,
Iam tryingto create a new dll in win32.
I am very new to vc++ environment. Please help me to test the application. I want both th dll and a test application in the same workspace so that I dont have to copy past the output dll everytime I update the dll project.
I have created a win32 dll. And I have added a new mfc(exe) project to the workspace to test my dll. I have given the output filename path of the dll to the mfc project.
is all my setting correct?
Can I write a small printf statement in the dllmain function to test my dll by running it (running the dll project?).
Thanks in advance
I am a learner Always
|
|
|
|
|
himangshuS wrote: I have given the output filename path of the dll to the mfc project.
Or you can set the working folder of exe project as the dll folder, to avoid dll copy.
himangshuS wrote: Can I write a small printf statement
printf is a console function. So AFAIK, you need the exe as a console app. If it is window/dialog app, then you can use
::MessageBox( 0, "My message", "From my dll", MB_SYSTEMMODAL );
himangshuS wrote: test my dll by running it (running the dll project?).
Yes, you can set the active project as dll and set the "executable for debug" as the exe. Also you can set the project dependency so that building of projects will be easier.
- ns ami -
|
|
|
|