|
I have several forms in the application that I would like to save to memory before writing all to disk. So the SetModifiedFlag() may not work in my case. There are two things that I would like to do. (1) When the user clicks on the Windows Close(X) button, what function do I need to override in order to do my custom save. Does a message call using WM_SYSCOMMAND with SC_CLOSE just closes the window? Depending on what function I override, it should be the same function I would use to call within my OnCancel() function when the user clicks on the Cancel button right? I am little confused on where and how the WM_SYSCOMMAND is used and if that is what I need.
Thanks!
|
|
|
|
|
I meant like this.You can map the WM_SYSCOMMAND for the MainFrame class.When the X button is clicked the value of nID will be SC_CLOSE.
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam) <br />
{<br />
if(nID == SC_CLOSE)
{<br />
CSaveDlg SaveDlg;<br />
if( IDOK == SaveDlg.DoModal() )<br />
{<br />
}<br />
}<br />
CFrameWnd::OnSysCommand(nID, lParam);<br />
<br />
}
|
|
|
|
|
I inserted the following code in CMainFrame class but nothing happens when I close the form. The save dialog box should appear but it doesn't. Am I doing something wrong or am I not doing something?
Thanks!
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
int save_button;
if(nID == SC_CLOSE) //Check If [X] Button
{
save_button = MessageBox(
"Save file",
"Save file data", MB_YESNO);
if (save_button == IDYES)
{
g_id->lp = lp_copy;
}
}
CFrameWnd::OnSysCommand(nID, lParam);
}
|
|
|
|
|
Code looks fine.Same thing works for me
But this will show the MessageBox when you are closing the main window.For the different FormViews you have to do this in the corresponding ChildFrame class.
Sorry
|
|
|
|
|
Can somebody give me good link that will give great information on -Remote Procedure Call.
I would like to know-
What are RPC based protocols.
What r the advantages of RPC
What r the disadvantages of RPC
Pls guide
|
|
|
|
|
Start here.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi
It is first message for you, because I regester in this site this month. Please talk to me about this site , its qualities , and other case of it.
Are you know the meaning of "MARZOGH"?
If YES,Please send for me.
|
|
|
|
|
mf14 wrote:
Please talk to me about this site , its qualities , and other case of it.
Well, its a site run for programmers by programmers.
It runs several forums dedicated to certain subjects. You posted this in the Visual C++ forum. You may have been better posting in the Lounge (see top right of browser window) to get better results.
It is also a great resource for articles on most if not all standard Microsoft technologies.
mf14 wrote:
Are you know the meaning of "MARZOGH"?
Sorry, cannot help with this one.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
I have an external file in notepad(.txt) and I have many lines of records in it:
example:
my name is jim
I have a car
it is a beautiful day
.
.
.
If I want to store the next four lines start from "my name is jim" to an array of string class, how can I do it?
I was trying to use strcmp to find line, but after I locate the line, I can only store one line into a string class.
How can I store the following three lines into the string classes?
|
|
|
|
|
Either store each following line in its own string (i.e. have 3 different string objects), or concatenate the strings.
e.g.
std::string str = "my name is jim";
str += "\n" + getLineFromInputFile();
//...
|
|
|
|
|
Hi
I am just starting out to learn C++ and I was wondering how long It took on average for you different people to lean and be throughly read on the subject??
|
|
|
|
|
It takes however long you want it to take. If you really crack down on it, and you're already comfortable with at least one other Object-Oriented programming language, you could become proficient in only a week or two. If you've never programmed or have only programmed in a structure-oriented language, expect to spend a month or two (possibly more), assuming you're willing to put a good bit of work into it. If you're not wanting to put the effort into coding, you'll probably never become proficient.
Code a lot if you want to learn C++, or any language. Find a project you are interested in, and write it in C++. Or write some module/component for it, if it's not a new project. And of course, read a lot of other people's code, paying attention to style (that means learning to recognize good AND bad C++ style).
|
|
|
|
|
Hi,
I started learning C++ about 5 years ago. At the moment, I still learn more about C++ and I still find interesting articles I should read.
After 5 months (C++ was my first programming language and it started as a hobby) I could understand almost every article, and I was able to use almost every well documented piece of code I could find.
I guess that the time to learn C++ depends on the person in question and his/her experiance in the field.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
---Mark--- wrote:
I was wondering how long It took on average for you different people to lean and be throughly read on the subject??
I'm on my 14th year of using C++...still learning.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I'm with you on that David
Ant.
|
|
|
|
|
I have two zip files
1. Normal
2. Corrupted
When in windows explorer when you take the cursor over
1 the normal zip file the tooltip shows-- zip file
2 the corrupted zip file the tooltip shows -- no zip file or bad zip file.
how can i achieve this file description in VC++
By using version info we can get the file description but that file needs to be an application it is not possible for normal files.
|
|
|
|
|
|
I'm trying to get the Target Folder path from a Folder Shortcut PIDL and I can't seem to find where this is or how to get it. From everything I've read it looked like a "simple" matter of binding an LPSHELLFOLDER variable to the PIDL, performing a QueryInterface (using IID_IPersistFolder3) and then calling its GetFolderTargetInfo method to get the goods. But it doesn't work. It looks like I can get the pointer to the Folder Shortcut's Shell Object, and it seems like the QueryInterface call succeeds to get a pointer to the IPersistFolder3 interface, but when I perform the GetFolder, the path values are empty and the PIDL doesn't look to be the same PIDL (in terms of its values not the address) I used on the BindToObject. I've been going round and round with this. Windows Explorer is privy to this information (shows up in the 'Target:' section of the Properties pop-up) so there's gotta be a way to get it. I need it to build a complete UNC or mapped drive path in my mini-browser for my app.
I've also tried seemingly obvious APIs like SHGetPathFromIDList() but this produces a path to the shortcut in the Documents folder, not the actual Target Folder. Any help would be greatly appreciated. Thanks in advance!
-Mike
P.S. Code snippet:
IPersistFolder3 * pPersistFolder = NULL;
IShellFolder * pSubFolder = NULL;
// pEnum->pshfParent references the 'My Network Places' PIDL in
// this scenario
hr = pEnum->pshfParent->BindToObject(
pItemIdList, // [in] folder shortcut PIDL
NULL,
IID_IShellFolder,
(VOID**) &pSubFolder);
// hr == S_OK && pSubFolder
hr = pSubFolder->QueryInterface(
IID_IPersistFolder3,
(VOID **) &pPersistFolder);
// hr == S_OK && pPersistFolder
PERSIST_FOLDER_TARGET_INFO targetInfo;
memset(&targetInfo, 0x00, sizeof(PERSIST_FOLDER_TARGET_INFO));
hr = pPersistFolder->GetFolderTargetInfo(
&targetInfo);
// Doesn't give the Target Location!
|
|
|
|
|
I know it's not healthy to talk to yourself, but I was able to solve this problem and thought I'd relay the fix in case anyone else was interested. I needed to use the IShellLink interface instead of the IPersistFolder3, using IShellLink::GetPath to get the UNC path.
|
|
|
|
|
I want to know if a dialog based program can be in the following style.
1. there is a title bar;
2. there is no caption on the title bar;
3. there is a caption on the windows task bar button.
<font=sans-serif>|-|3llo Wo|2ld
|
|
|
|
|
1. there is a title bar;
BOOL bHasTitleBar = this->GetStyle() & WS_CAPTION;
2. there is no caption on the title bar;
CString sCaption;
this->GetWIndowText(sCaption);
BOOL bHasCaptionOnTheTitleBar = sCaption.GetLength() > 0;
3. there is a caption on the windows task bar button.
BOOL bHasTaskBarButton = (this->IsWindowVisible() && this == AfxGetMainWnd());
|
|
|
|
|
=[ Abin ]= wrote:
// Huh? If a window has caption on its title bar, then
// it also has the same caption on the system task bar button,
// if it does have a task bar button.
// If you mean "this window has a task bar button"
I mean this window has a task bar button with caption as well as a title bar without caption. The requirements are quite strange and make me hard to implement. I am now considering if i can set the caption color to transparent or to the same of the title bar. Do you have any idea?
Thanks very much
<font=sans-serif>|-|3llo Wo|2ld
|
|
|
|
|
Requirements 2 & 3 collide. As you already know...
But you can cheat. Set a title as you normally would. Then handle the WM_NCPAINT message
and draw the title bar yourself (and don''t bother drawing the text!).
For examples of custom title bars, search codeproject for WM_NCPAINT and OnNcPaint .
And I agree, it is a strange request!
Iain.
|
|
|
|
|
Hi all,
I have an ASCII file, i want to read the content of the file, and then display it on the CRichEditCtrl. The point is i want to display all the control characters (especially \t \r \n) as a symbol (like a square) instead of interpreting it (e.g. making spaces for \t).
Really appreciate if s.o could help.
Thanks
|
|
|
|
|
So how about reading the contents of the file into a CString object, and use the Replace() method to replace all \t \r \n characters with said square?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|