|
Erik wrote: So how can I distinguish if it's a really a file or only a folder?
There's also GetFileAttributes() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi All,
I need to create a notepad in Dialog based MFC application.I need some idea about this.
Help me......
Thanks & Regards,
Anitha
|
|
|
|
|
AnithaSubramani wrote: I need to create a notepad in Dialog based MFC application.
Creating a SDI application and deriving view class from CEditView would be better choice for this.
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
Hi,
I need a example code.pls help me....
|
|
|
|
|
Does Notepad with RE[^] help?
It is advanced but you can get started.
If you want you can even follow this tutorial Creating notepad[^]
BTW:
AnithaSubramani wrote: pls help me....
No need to write this in every post.
Everyone here will help you provided you give sufficient information.
Regards,
Sandip.
|
|
|
|
|
|
AnithaSubramani wrote: I need a example code.
Open Visual Studio. Create a new SDI project. Derive the view from CEditView .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
AnithaSubramani wrote: I need a example code
You can create a working notepad application with the App Wizard.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I want my control (CButton derived) has the same behaviour if CLICKED and DOUBLECLICKED.
Now, it is working well if CLICKED...I need to extend the functionality on DOUBLCLICK.
So, I simply added
ON_CONTROL_REFLECT_EX(BN_DOUBLECLICKED, CMyCButton::OnBnDblClicked)
In that function I want to do some similar to
BOOL CMyCButton::OnBnDblClicked(){
PostMessage(WM_COMMAND, MAKELONG(GetDlgCtrlID(), BN_CLICKED), (LPARAM) GetSafeHwnd());
return TRUE;
}
But in that way only my control receive the message BN_CLICKED , not the parent Dialog.
Please, what is the right way to send/post to the control (together to it's parent) that message?
Russell
|
|
|
|
|
Have a look at here[^]...
|
|
|
|
|
Thank you....but your solution looks work as my previus one, i.e. it is a perfect solution to manage the message inside the control, but his parent window doesn't receive the classic message BN_CLICKED
My be also I'm wronging something...
BOOL XBmpChkBtn::OnBnDblClicked(){
const MSG* pstMSG = GetCurrentMessage();
DefWindowProc(WM_COMMAND, MAKELONG(GetDlgCtrlID(), BN_CLICKED), (LPARAM) GetSafeHwnd());
return TRUE;
}
Russell
|
|
|
|
|
Please correct as
DefWindowProc( WM_LBUTTONDOWN, pstMSG->wParam, pstMSG->lParam );
|
|
|
|
|
The solution looks:
BOOL CMyCButton::OnBnDblClicked(){
GetParent()->PostMessage(WM_COMMAND, MAKELONG(GetDlgCtrlID(), BN_CLICKED), (LPARAM) GetSafeHwnd());
return TRUE;
}
or the same of:
ON_CONTROL_REFLECT(BN_DOUBLECLICKED, CMyCButton::OnBnDblClicked)
and
BOOL CMyCButton::OnBnDblClicked(){
GetParent()->PostMessage(WM_COMMAND, MAKELONG(GetDlgCtrlID(), BN_CLICKED), (LPARAM) GetSafeHwnd());
}
but I'm not sure that it is the right way to manage messages when using derived controls, I was aspecting to do everything inside the control class: that call to GetParent() looks strange to me.
any comments?
Russell
|
|
|
|
|
You posted the solution for yourself.
You are handling the conversion from BN_DOUBLECLICKED to BN_CLICKED in the button control as you desire.
But the whole purpose was to change the message to the parent from BN_DOUBLECLICKED to BN_CLICKED.
So you need to send / post the message to the parent. Which the GetParent () helps you with. If it makes it clearer for you, try this:
BOOL CMyCButton::OnBnDblClicked()
{
HWND hButton = GetSafeHwnd ();
HWND hDialog = GetParent (hButton);
::PostMessage(hDialog, WM_COMMAND, MAKELONG(GetDlgCtrlID(), BN_CLICKED), (LPARAM)hButton);
}
Ends up being the same though. I'd use SendMessage rather than PostMessage, but that's a different question.
Iain.
|
|
|
|
|
I'm according to you
Thank you
Russell
|
|
|
|
|
This is the code i used ..........To CREATE a File
and enter a default string..
...........Ive TO USE VC++ MFC
void CFileApp::OnInsert()
{
HANDLE hFile = CreateFile(_T("C:\\Documents and Settings\\MyFile.ini"),
GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
AfxMessageBox(_T("Couldn't create the file!"));
else
{
// Attach a CFile object to the handle we have.
CFile myFile(hFile);
static const char sz[] = "Hockey is best!";
// write string, without null-terminator
myFile.Write(sz, lstrlen(sz));
myFile.Close();
}
}
This works.....
BUt For INI I want to ENTER DATA SECTIN-WISE....
...........
Here Data is written just like in Text files...
I need to use ...GetProfileString....
WriteProfileString..... n so on...
how do i do it??
I NEED TO MAKE A PHONE DIRECTORY USING INI FILE......
|
|
|
|
|
Do you plan to use as configuration file for your application ? If yes, this is a bit an outdated way of doing this. More recent applications use the registry to store config options.
If you choose to use the registry, search for articles on CP, there are really a lot. They should get you started.
|
|
|
|
|
No... Im not using INI File to store confiq info...
IM USING INI FILE TO CREATE A PHONE DIRECTORY...
i know there r better methods...
BUT ITS MY ASSIGNMENT....
..........N ITS SAID THAT I USE ONLY INI FILE
|
|
|
|
|
anna mathew wrote: IM USING INI FILE TO CREATE A PHONE DIRECTORY...
As I already suggested, MFC object serialization, is far better for the purpose.
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]
|
|
|
|
|
The following code snippet create two keys under the section 'General' of the File 'MyFile.ini', and then reads one of the keys, showing the value in a message box.
(of course error check is left to the reader...)
Please note 1: if the file doesn't exist, it creates both the file and the section.
Please note 2: I used WritePrivateProfileString and GetPrivateProfileString , otherwise the I/O would happen inside the registry.
const CString szINIFILE = _T("C:\\Documents and Settings\\anu\\beginning\\MyFile.ini");
CString szFirstName;
WritePrivateProfileString(_T("General"),_T("FirstName"), _T("Anu"), szINIFILE);
WritePrivateProfileString(_T("General"),_T("LastName"), _T("???"), szINIFILE);
GetPrivateProfileString(_T("General"), _T("FirstName"), _T(""), szFirstName.GetBuffer(MAX_PATH), MAX_PATH, szINIFILE);
szFirstName.ReleaseBuffer();
AfxMessageBox(szFirstName);
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]
|
|
|
|
|
Thanks....
this works....
but i put the same lines of code in my MFC
application....
still it works....
can u explain how?
WriteProfileString...... is a console function...
then how come it work with MFC?
|
|
|
|
|
WritePrivateProfileString is just a WIN32 API 's function: Console applications, as well as GUI (and MFC ) ones can profitably call it.
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]
|
|
|
|
|
|
The control will popup a dialog box,
and when I press a buttion in the dialog,
I need the control fire a event?
I tried to do it as below:
CMyDlg::OnOk
{
CMyCtrl *pCtrl = dynamic_cast<>(GetParent());
...
pCtrl->OnUpdate(var);
}
How to solve it?
modified on Monday, November 3, 2008 7:03 AM
|
|
|
|
|
I would like to know how to configure the ip address of a notebook PC. I only want to configure the wireless network adaptor how can I identity it if I don't know the name of the wireless network adaptor.
Also, how to configure the adhoc mode in the notebook by Visual C++?
Please help!!!
|
|
|
|