|
Hi!
Try this:
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CView* pView = (CView*)pFrame->GetActiveView();
MSc Bertil Morefält
|
|
|
|
|
hi,
in following code while creating object to cfiledialog it return handle null. what's the problem. any one help to me.
CString CStrExt;
CStrExt = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||";
CFileDialog SelDialog(TRUE, CStrExt, NULL, OFN_HIDEREADONLY | OFN_ENABLETEMPLATE,NULL,this);
SelDialog.m_ofn.lpTemplateName = "Open";
SelDialog.m_ofn.hInstance = AfxGetInstanceHandle();
if(SelDialog.DoModal() == IDOK)
{
MessageBox(SelDialog.GetPathName());
}
thanks in advance.
Murali.M
|
|
|
|
|
Hi
Alway use CommDlgExtendedError to figure out what is wrong with common dialogs.
Next Use
static char BASED_CODE szFilter[] = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||";
static char BASED_CODE szFilter[] = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||";
CFileDialog fileDialog(true, NULL, NULL,
(OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST),
szFilter);
fileDialog.m_ofn.lpstrTitle = _T("Choose Files");
//fileDialog.m_ofn.lpTemplateName = "Open";
// need larger filename buffer to support multiselect
TCHAR filenameBuffer[4096] = { 0 } ;
fileDialog.m_ofn.lpstrFile = filenameBuffer;
fileDialog.m_ofn.nMaxFile = sizeof(filenameBuffer) / sizeof(filenameBuffer[0]);
if (IDOK == fileDialog.DoModal())
{
POSITION pos = fileDialog.GetStartPosition();
while (pos != NULL)
{
CString filename = fileDialog.GetNextPathName(pos);
AfxMessageBox(filename);
}
AfxMessageBox("Set Modified Flag");
}
else
{
DWORD errCode = CommDlgExtendedError();
switch (errCode)
{
case 0:
TRACE(_T("User cancelled Extract dialog\n"));
break;
// case FNERR_BUFFERTOOSMALL: // define if needed like #define FNERR_BUFFERTOOSMALL 0x000100
// ::AfxMessageBox(_T("Too many files selected. Try again with fewer files."));
// break;
default:
::AfxMessageBox(_T("An error occurred"));
break;
}
}
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Hello. I am somewhat a beginner myself therefore I don't know enough to go into "complete detail". If you are trying to do a normal file selection dialog box, you don't really need to use OFN_ENABLETEMPLATE. I'm pasting some code for you below. Notice one thing from your original post. You have CStrExt in the wrong place. The second parameter to construct this dialog is:
lpszDefExt
The default filename extension. If the user does not include an extension in the Filename edit box, the extension specified by lpszDefExt is automatically appended to the filename. If this parameter is NULL, no file extension is appended.
That's just a default extension. Say the dialog box pops up, and there's a file in there called "test.txt". If the default filename extension was set to ".txt" and I typed in "test" to the dialog box, it would automatically append ".txt" to the end of it allowing me to quickly select the file without having to type in "test.txt".
So, your CStrExt should actually go in the 5th place, which is:
lpszFilter
A series of string pairs that specify filters you can apply to the file. If you specify file filters, only selected files will appear in the Files list box. See the Remarks section for more information on how to work with file filters.
Give that a try. That shall present a dialog box and work for you. I am not really sure (as I said I am a beginner myself) how the templates work, but I'm pretty sure that's where your problem is in there. You are trying to use a template and there is something not right in there so when you try to construct the dialog box, the program cannot find the template handle that you are trying to use, and therefore never brings up the box.
This code here will work for you:
CString CStrExt;
CStrExt = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"; // a more appropriate name
// would be CStrFilter
//Either of the following work. The first one with the ",0" at the end will make a nicer looking
// dialog box that has my computer, etc on the left hand side. The second one makes
// a normal "older style" dialog box. (for WXP)
// CFileDialog SelDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY,CStrExt,this,0);
CFileDialog SelDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY,CStrExt,this);
if(SelDialog.DoModal() == IDOK)
{
MessageBox(SelDialog.GetPathName());
}
Hope that helps you out.
|
|
|
|
|
hi shultas thanks for ur help.
Have A Nice Day.
|
|
|
|
|
Hello,
I seem to have a weird problem - I can compile all of my projects, some of which use gcc and others use VC++, just fine at work, and also fine at one of my computers at home. The other computer, however, seems to not recognize the changed/unchanged flags on my files, and it will either not compile anything, or do a full compile when I've only changed one file. It only began to do this after I brought the projects back from work (using windows XP professional while both my home machines use windows XP home edition), whereas before I did them at work they compiled fine.
This is a real pain in the butt, any help would be appreciated..
Thanks
Kelly Ryan
|
|
|
|
|
Oop, somehow the date on my computer here was screwed up, set for 5 days earlier than the other computers.. so it kept thinking that all my files were updated... oh well, sorry to waste your time.
Kelly Ryan
|
|
|
|
|
I have a dialog in which two list boxes are present with some data in it. How do I print this?
|
|
|
|
|
Hi pls find the solution for this here..
http://www.codeproject.com/useritems/printlistctrl.asp
S.SunilKumar
Sr.Software Engineer
|
|
|
|
|
|
Hello everyone,
I am using CreateProcess in a MFC-based application to run another independent app. However, everytime the independent application finishes, the MFC app freezes. I think it could be caused by memory leak in the independent app. But CreateProcess is supposed to create an independent application. right?
cchere
|
|
|
|
|
Hello,
yes. Createprocess run another application .
Try WinExec function
With Regards,
R.Selvam
|
|
|
|
|
Yes, WinExec can do it. Thanx a lot.
|
|
|
|
|
While WinExec() might keep your MFC application from freezing, it would appear that you've simply masked the problem.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
That is true. I suspect that there is some memory leak in another application. Since it was written by somebody else, I am not going to fix it now
|
|
|
|
|
cchere wrote:
I suspect that there is some memory leak in another application.
You can always use the Performance monitor (MMC plug-in) to verify this.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Thanks Dave. You are so resourcefule. I will try MMC myself.
|
|
|
|
|
cchere wrote:
But CreateProcess is supposed to create an independent application. right?
What value(s) did you use for dwCreationFlags?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I use CREATE_NEW_CONSOLE|CREATE_DEFAULT_ERROR_MODE.
|
|
|
|
|
How can I calculate the new size of a picture
to be printed on the printable area of a page.
In another words, the same formula I am using to
display any size picture on the client area of
the program, does NOT work with the printer.
It almost does it, but always cut just a little bit
of the right side of the picture.
( Landscape ---- left to right )
|
|
|
|
|
Hi there,
I haven't got a huge amount of experience with DLLs so go easy on me.
I have a DLL which is working fine. I need to write a .exe which calls two of the DLL's methods.
The class declaration in the header file of the DLL looks like this:
class CFaCSMenuApp : public CWinApp<br />
{<br />
public:<br />
CFaCSMenuApp();<br />
__declspec(dllexport) void AttachFromImanage();<br />
DECLARE_MESSAGE_MAP()<br />
};
The .exe file looks like this:
class DllFire<br />
{<br />
public:<br />
__declspec(dllimport) void AttachFromImanage();<br />
DllFire();<br />
};<br />
<br />
int main()<br />
{<br />
DllFire df;<br />
df.AttachFromImanage();<br />
return 0;<br />
}
When I try to compile it I get the following output:
Compiling...
Test.cpp
Linking...
Test.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall DllFire::AttachFromImanage(void)" (__imp_?AttachFromImanage@DllFire@@QAEXXZ)
Test.obj : error LNK2001: unresolved external symbol "public: __thiscall DllFire::DllFire(void)" (??0DllFire@@QAE@XZ)
Debug/SIStarterCon.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
SIStarterCon.exe - 3 error(s), 0 warning(s)
What am I doing wrong here? I have put the .lib file created by the dll in the Object/Library modules section of the project settings.
Cheers, Ben
|
|
|
|
|
Well, calling dll from exe is straight forward if you use static linking. Just add .lib file name to the library link section of .exe settings. make sure when compiler links, it can find where .lib is located. Also, in the .exe source code you will need to add #include "yourdll.h" header file. Compiler must also know where is that .h file is located.
Hope that helps,
|
|
|
|
|
I'm trying to solve a puzzle, how to implement a timeline chart. I tried creating my own class with a list control and a slider control as members. But I can't get them to synch. Any ideas? Thanks in advance.
|
|
|
|
|
Does anybody know how to change the source url for a web service in VC++ without manually changing the generated proxy file from sproxy.exe?
There's no direct method and the TClient (CSoapSocketClientT) which holds the information is not accessible directly. I also tried to derive a new template from the generated one and thereby setting the TClient url, but the base class ignores it, and uses the info from the generated file.
It's starting to annoy me that I cannot change it, so any help will be appriciated
/Boris
|
|
|
|
|
...must be more tired than I thought when I didnt see the obvious
|
|
|
|