|
Could this be of any help :
Article[^]
~RaGE();
|
|
|
|
|
How to open a default fil by using the CFileDialog class
I open the dialog box like this .
I want to keep one file as default selection
CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|");
dlg.DoModal ();
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Use
<br />
dlg.m_ofn.lpstrFile=TEXT("DefaultFile.xxx");<br />
before DoModal()
Have a nice code day
|
|
|
|
|
I need to open a file named "1.bmp" located as "c:\1.bmp"
but i get assertion for invalid address
ASSERT(AfxIsValidAddress(m_ofn.lpstrFile, m_ofn.nMaxFile));
My code is somthing like this :--------
CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|");<br />
<br />
dlg.m_ofn.lpstrFile=TEXT("c:\\1.bmp");<br />
<br />
dlg.DoModal ();
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
sorry (error),
now try with this:
<br />
TCHAR str[100]=TEXT("c:\\1.bmp");<br />
dlg.m_ofn.lpstrFile=str;<br />
Have a nice code day
|
|
|
|
|
sorry there is some problem in the given code also
some assertion at
ASSERT(m_hFile != (UINT)hFileNull);
I thing will have to go through the sturctre method
i found some links will try from it
http://eatworms.swmed.edu/~boris/B_Player/VideoWnd.cpp
http://www.codeproject.com/dialog/remove_filters.asp
Why simpe things are done so complicated in VC++
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I don't know, it is strange!
A good thing could be add the flag OFN_FILEMUSTEXIST here:
CFileDialog dlg(TRUE,"bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Only BMP (*.bmp)|*.bmp|");
So you are sure that the file exist.
And I don't like very much
...,"Only BMP (*.bmp)|*.bmp|"
I prefere
...,"Only BMP (*.bmp)|*.bmp||"
Let me know
Have a nice code day
|
|
|
|
|
I will have to get the exact error if u have tested the code
so u might be right ,
can be some error in my code .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
_Russell_ wrote: dlg.m_ofn.lpstrFile=str;
If lpstrFile is assigned a non-NULL value, so must nMaxFile also be used to indicate the size of the buffer pointed to by lpstrFile .
Why do it this way, however, when the constructor already has provisions for such?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
vikas amin wrote: How to open a default fil by using the CFileDialog class
That is what the third parameter of CFileDialog 's constructor is for.
vikas amin wrote: I need to open a file named "1.bmp" located as "c:\1.bmp"
Then why bother with CFileDialog if you already know the name of the file?
Also, the filter should end with two ‘|’ characters.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
yep if he knows filename & location then why he is using CFileDialog .
well i guess he wants to show his skills here.;)
|
|
|
|
|
vikas amin wrote:
I need to open a file named "1.bmp" located as "c:\1.bmp"
Then why bother with CFileDialog if you already know the name of the file?
Yeh good qestion , i need this only for Testing purpose &
when i cannot reach some thing in coding
it makes me crazy to get it done .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
please tell me what's a callback function?
i've read it many times but i'm understanding it. whats the differnce between CallBack function and a normal function. please dont give a link. which i'm not going to understand. instead explain me.. with a little example. pleeeeeez
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
A callback function is a normal function that the system calls when comes specified events.
An event could be a mouse click, or a tollbar botton click, ....
To link the event to the function it is used the MESSAGE_MAP
(usually in this macros are used the IDs of the objects that the user is using)
is it OK?
Have a nice code day
|
|
|
|
|
fisrt of all thanks for your patience,
for the first time i think i've understood whats a callback.
See here
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,WPARAM wParam, LPARAM lParam)
as i've read,WndProc processes all the messages send by the applications. right? so a message "coming" makes an event which inturn calls this CALLBACK wndProc right? am i right?
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
Rokiee wrote: am i right?
Yes.
Have a nice code day
|
|
|
|
|
can i come with another dumb question?? later?
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
Rokiee wrote: can i come with another dumb question??
Of course you can. This is the purpose of this message board
|
|
|
|
|
so nice of you
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
Of course!!!
The problem could be only this:
Am I a good programmer, to solve your question? We will see.
Bye
Have a nice code day
|
|
|
|
|
Rokiee wrote: another dumb question??
The only dumb question is the one that's never asked. So ask away! We're here to help.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Following is a funciton where I am calling a thread
void CMyView::OnInitialUpdate()
{
...
AfxBeginThread(Thread_ScanConnectionState, m_sComPort, THREAD_PRIORITY_NORMAL, NULL, NULL, NULL);
...
}
//Foll is the thread definition
UINT CMyView::Thread_ScanConnectionState(LPVOID pParam)
{
CString sComPort;
sComPort = static_cast<lpcstr> (pParam);
return 1;
}
The declaration of the thread in the class header of CMyView is as below.
UINT Thread_ScanConnectionState( LPVOID pParam );
I get the compilation error as given below
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'UINT (LPVOID)'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4105): could be 'CWinThread *AfxBeginThread(AFX_THREADPROC,LPVOID,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4108): or 'CWinThread *AfxBeginThread(CRuntimeClass *,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
while trying to match the argument list '(overloaded-function, CString)'
Please let me know the error.
laiju
|
|
|
|
|
Hi,
First: AfxBeginThread takes a static function pointer. Yours is not a static function. IOW, make Thread_ScanConnectionState static.
Second: In the func nody you typed 'static_cast(pParam)': incorrect.
The correct is:
sComPort = static_cast<cstring> (pParam);
Third: Do not do extra typing: AfxBeginThread's default parameters work fine.
You need not pass THREAD_PRIORITY_NORMAL or the NULLs.
--
======
Arman
|
|
|
|
|
Second: In the func nody you typed 'static_cast(pParam)': incorrect.
The correct is:
sComPort = static_cast (pParam);
Sorry, it seems the editor doesn't love static_cast's signature
--
======
Arman
|
|
|
|
|
Arman Z. Sahakyan wrote: Sorry, it seems the editor doesn't love static_cast's signature
the editor is just html, so don't use html tags...
<> are interpreted.
if you don't want it to, check the Ignore HTML tags in this message (good for code snippets) checkbox or use < > codes instead...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|