|
Ok, I work with VB professionally, however I am about to make the jump into working on a possible project using MFC (applaud later ). I know this may sound like a dumb question but if I wanted to have a button show what a dialog window to open a file I know in VB we use the CommonDialog component. What do you do for MFC? I was looking around and I can see that you can insert a resource but that wasn't very clear to me. Can someone point me in the right direction, thanks in advance?
Nick Parker
|
|
|
|
|
|
Michael Dunn wrote:
I think you're talking about the standard file open dialog? MFC has CFileDialog.
Thanks Mike,
That's exactly what I was looking for.
I tried to do
CFileDialog cf;
cf.ShowWindow();
but I get an error saying "'CFileDialog' : no appropriate default constructor available"
Nick Parker
|
|
|
|
|
RTFM
The CFileDialog constructor has one manadatory parameter, a BOOL indicating whether it's for opening (TRUE) or saving (FALSE). So something like:
CFileDialog dlg ( TRUE );
if ( IDOK == dlg.DoModal() )
{
CString sSelectedFile = dlg.GetPathName();
} You use DoModal() to show a modal dialog.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Crap! You type faster than me!
|
|
|
|
|
Michael Dunn wrote:
RTFM
Which one do you suggest, really? I will give it a try.
Thanks Mike, hopefully I won't get stuck so quickly next time.
Nick Parker
|
|
|
|
|
Just put the cursor on the word CFileDialog, then hit F1 to jump right to the MSDN page on the class.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
WEll, you need to use the non-default constructor.
This is from MSDN.
CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL );
so, CFileDialog cf(TRUE); will give you a default Open File dialog.
So you were on the right track.
MSDN is very helpful with this kind of information (either online or integrated into VisualStudio).
Hope this helps!
|
|
|
|
|
I want to realize the effect like Book page turning (flip),How can I make it,
where can I find a sample code ,thanks a lot!
|
|
|
|
|
I used LeadTools[^] for this. Their library is pretty cool. They have quite a few other transitions too.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
But I want the VC source code which can help me to make it,where can I find it?
|
|
|
|
|
If it was easy and commonly available then Leadtools would not be making a quid out of it, would they ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
that's the trouble with a site like this ... people get spoiled
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
Jesus Would Read The Fxxxxx Manual ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
yep. cause Jesus wasn't dumb.
-c
WWJD? JWRTFM. found on /.
|
|
|
|
|
Hi -
Does anyone know how to change the browser mouse cursor for a item when the mouse goes over it, I need to have a custom cursor that looks like any image I want for when the mouse goes over it for IE 5.5. I want to program a small activeX style plug-in which can change the mouse cursor. Any idea how to do this?
Cheers, Phil
|
|
|
|
|
http://www.dynamicdrive.com[^] has a nice collection of JavaScript goodies.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have derived a class from CWnd and added it to a dialog using the custom control 'control' (I feel like Austin Powers)
Anyways...I wanna initialize the damn thing, but I don't know what fricken function to do so in...
PreSubclassWindow doesn't seem to work
I used Chris's Bitmap Viewer Custom Control article as a template so i'm lost as to why the above isn't working...???
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hockey wrote:
PreSubclassWindow doesn't seem to work
It should. Can you put the breakpoint in the function and check if it fires?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
I figured out the trivial problem...my bad...
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
What bitwise operator/combination would I use to force a bit...???
Would the following yield the result im looking for..?
1 & 0 = 1
1 & 1 = 1
Basically I wanna ensure the WS_VISIBLE bit is always set.
dwStyle & WS_VISIBLE would accomplish this yes...???
Thanx
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
dwStyle |= WS_VISIBLE; /ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanx
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I believe that you use the (dwStyle & WS_VISIBLE) to test if WS_VISIBLE bit is set in dwStyle, which might help you with what you want.
However a better way to do this is to use the OR operator ( it's the | : shift+\) the OR operation results in true if any of the arguments was true and false if none were true.
ie 1 or 1 = 1
1 or 0 = 1
0 or 1 = 1
0 or 0 = 0
while the AND (&) is only true if both arguments were true.
Since WS_VISIBLE is always true, the | operator with dwStyle and WS_VISIBLE will always force the bit you are interested in to true. The usage should be along the lines of:
dwStyle= dwStyle | WS_VISIBLE;
This will make sure that the flag bit is forced to true while the rest of the bits are unmodified (since WS_VISIBLE has only one bit turned to true).
exp:
dwStyle 1001110101110111
WS_VISIBLE 0000000010000000
Binary OR (|) 1001110111110111
this is called the Binary OR since it compares bits and results in bits, & is Binary AND too. && and || are the logical operators and compare the arguments bit by bit by return only true or false.
Please correct me if I'm wrong, it's been quite a while ...
-<msh>-
Young Basic programmers never die... they just GOSUB and never RETURN.
|
|
|
|
|
Thanx
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|