CFileDialog and PreTranslateMessage

Hello, I have a CFileDialog derived class.
I want to handle the backspace key down in my derived class.
I added PreTranslateMessage handler to my class but it never gets in there 
(Why?).
What can I do in order to handle the Back_Space key down in my derived 
class?
Thanks,
Janiv Ratson.


0
janiv (189)
8/10/2005 4:04:43 PM
vc.mfc 33608 articles. 0 followers. Follow

12 Replies
552 Views

Similar Articles

[PageSpeed] 29

First of all you did not mention what control you want to receive 
notification when del key was pressed.
Secondly you should not use PreTranslateMessage in this manner; it was not 
designed for that and it is a source of many problems that usually are not 
foreseen.

You have to provide more detailed information about your problem.

You can go to CodeGuru and lookup FAQ for reasons why not to use 
PreTranslateMessage. See questions about how to suppress Enter key from 
closing a dialog.

-- 
RainMan


"Janiv Ratson" wrote:

> Hello, I have a CFileDialog derived class.
> I want to handle the backspace key down in my derived class.
> I added PreTranslateMessage handler to my class but it never gets in there 
> (Why?).
> What can I do in order to handle the Back_Space key down in my derived 
> class?
> Thanks,
> Janiv Ratson.
> 
> 
> 
0
RainMan6256 (150)
8/10/2005 8:26:07 PM
What messages are you handling?  Generally, redefining a key as significant as backspace
in a dialog as rigidly specified as CFileDialog is begging for problems, but you need to
show us some code so we can offer some ideas.  Why do you need to redefine the meaning of
the backspace key?
				joe

On Wed, 10 Aug 2005 18:04:43 +0200, "Janiv Ratson" <janiv@aoe6.net> wrote:

>Hello, I have a CFileDialog derived class.
>I want to handle the backspace key down in my derived class.
>I added PreTranslateMessage handler to my class but it never gets in there 
>(Why?).
>What can I do in order to handle the Back_Space key down in my derived 
>class?
>Thanks,
>Janiv Ratson.
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
8/10/2005 9:00:34 PM
Just off the top of my head, I'm assuming that you added the handler in your
CMyFileDialog class.

I suspect the nub of the probem lies in the fact that your class is not the
hierarchical parent of the dialog that you see on the screen. To put it
another way, your class actually becomes a child of the file open dialog
window. Use Spy to look at the hierarchy and you'll see what I mean. It
appears that the real dialog window (which I assume does get the message)
examines the various messages and decides to whom it should pass on
messages.

But that's just off the top of my head.


"Janiv Ratson" <janiv@aoe6.net> wrote in message
news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
> Hello, I have a CFileDialog derived class.
> I want to handle the backspace key down in my derived class.
> I added PreTranslateMessage handler to my class but it never gets in there
> (Why?).
> What can I do in order to handle the Back_Space key down in my derived
> class?
> Thanks,
> Janiv Ratson.
>
>


0
kma1 (58)
8/11/2005 5:47:03 AM
Janiv,

Then you could be in luck. The real parent dialog does send some useful
messages to your class, one of which is overriden as OnFolderChange. At
least in this handler you get to find out when the user has tried to change
folder. I guess you can trap this and take action to prevent access to
particular folders. I haven't actually tested this.

"Janiv Ratson" <janiv@aoe6.net> wrote in message
news:Oi9MqCknFHA.708@TK2MSFTNGP09.phx.gbl...
> Hello and thanks,
> I'll try to explain myself better.
>
> If you'll open a windows standard File Dialog and set the focus on the
> listcontrol(where the folders and files are shown), and than you press the
> Back_Space button, the list control will change directory to the parent
one,
> another press on the Backspace button will again take you to the parent
> directory and so on.
> What I want to do in my derived CFileDialog is to enable the user to go up
> one level(directory), until a specific directory, Hence limit the user
> capability to go to up level until the root directory.
> I want to limit the user directories to choose a file from.
>
> I hope it is clear enough.
> Thanks,
> Janiv Ratson.
>
>
> "KMA" <kma@chum.com> wrote in message
news:ddeooo$eh8$1@atlas.ip-plus.net...
> > Just off the top of my head, I'm assuming that you added the handler in
> > your
> > CMyFileDialog class.
> >
> > I suspect the nub of the probem lies in the fact that your class is not
> > the
> > hierarchical parent of the dialog that you see on the screen. To put it
> > another way, your class actually becomes a child of the file open dialog
> > window. Use Spy to look at the hierarchy and you'll see what I mean. It
> > appears that the real dialog window (which I assume does get the
message)
> > examines the various messages and decides to whom it should pass on
> > messages.
> >
> > But that's just off the top of my head.
> >
> >
> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
> > news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
> >> Hello, I have a CFileDialog derived class.
> >> I want to handle the backspace key down in my derived class.
> >> I added PreTranslateMessage handler to my class but it never gets in
> >> there
> >> (Why?).
> >> What can I do in order to handle the Back_Space key down in my derived
> >> class?
> >> Thanks,
> >> Janiv Ratson.
> >>
> >>
> >
> >
>
>


0
kma1 (58)
8/11/2005 7:33:05 AM
Hello and thanks,
I'll try to explain myself better.

If you'll open a windows standard File Dialog and set the focus on the 
listcontrol(where the folders and files are shown), and than you press the 
Back_Space button, the list control will change directory to the parent one, 
another press on the Backspace button will again take you to the parent 
directory and so on.
What I want to do in my derived CFileDialog is to enable the user to go up 
one level(directory), until a specific directory, Hence limit the user 
capability to go to up level until the root directory.
I want to limit the user directories to choose a file from.

I hope it is clear enough.
Thanks,
Janiv Ratson.


"KMA" <kma@chum.com> wrote in message news:ddeooo$eh8$1@atlas.ip-plus.net...
> Just off the top of my head, I'm assuming that you added the handler in 
> your
> CMyFileDialog class.
>
> I suspect the nub of the probem lies in the fact that your class is not 
> the
> hierarchical parent of the dialog that you see on the screen. To put it
> another way, your class actually becomes a child of the file open dialog
> window. Use Spy to look at the hierarchy and you'll see what I mean. It
> appears that the real dialog window (which I assume does get the message)
> examines the various messages and decides to whom it should pass on
> messages.
>
> But that's just off the top of my head.
>
>
> "Janiv Ratson" <janiv@aoe6.net> wrote in message
> news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
>> Hello, I have a CFileDialog derived class.
>> I want to handle the backspace key down in my derived class.
>> I added PreTranslateMessage handler to my class but it never gets in 
>> there
>> (Why?).
>> What can I do in order to handle the Back_Space key down in my derived
>> class?
>> Thanks,
>> Janiv Ratson.
>>
>>
>
> 


0
janiv (189)
8/11/2005 7:44:57 AM
Alright. Use Spy to find out who gets the keydown message. I assume it's the
listctrl, or rather that the listctrl must have focus for this functionality
to happen.

Then you need to hook this window/ctrl in order to intercept the
WM_KEYDOWNs. When you get VK_BACK as an input paramter you need to fugure if
the user is allowed to go up one dir and either call the default
functionality or not accordingly.

Do bear in mind that the listctrl is held within a container, so to locate
it you have to do a bit of jiggery pokkery through the dialog hieracrchy,
but Spy will show you where it is.

"Janiv Ratson" <janiv@aoe6.net> wrote in message
news:uElSwGlnFHA.3408@tk2msftngp13.phx.gbl...
> Hello and thanks,
> I tried that, but the OnFolderChange notification is sent to me after the
> folder has changed, and I want to prevent the change of the directory.
> Thanks,
> Janiv Ratson.
>
> "KMA" <kma@chum.com> wrote in message
news:ddeuvh$eud$1@atlas.ip-plus.net...
> > Janiv,
> >
> > Then you could be in luck. The real parent dialog does send some useful
> > messages to your class, one of which is overriden as OnFolderChange. At
> > least in this handler you get to find out when the user has tried to
> > change
> > folder. I guess you can trap this and take action to prevent access to
> > particular folders. I haven't actually tested this.
> >
> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
> > news:Oi9MqCknFHA.708@TK2MSFTNGP09.phx.gbl...
> >> Hello and thanks,
> >> I'll try to explain myself better.
> >>
> >> If you'll open a windows standard File Dialog and set the focus on the
> >> listcontrol(where the folders and files are shown), and than you press
> >> the
> >> Back_Space button, the list control will change directory to the parent
> > one,
> >> another press on the Backspace button will again take you to the parent
> >> directory and so on.
> >> What I want to do in my derived CFileDialog is to enable the user to go
> >> up
> >> one level(directory), until a specific directory, Hence limit the user
> >> capability to go to up level until the root directory.
> >> I want to limit the user directories to choose a file from.
> >>
> >> I hope it is clear enough.
> >> Thanks,
> >> Janiv Ratson.
> >>
> >>
> >> "KMA" <kma@chum.com> wrote in message
> > news:ddeooo$eh8$1@atlas.ip-plus.net...
> >> > Just off the top of my head, I'm assuming that you added the handler
in
> >> > your
> >> > CMyFileDialog class.
> >> >
> >> > I suspect the nub of the probem lies in the fact that your class is
not
> >> > the
> >> > hierarchical parent of the dialog that you see on the screen. To put
it
> >> > another way, your class actually becomes a child of the file open
> >> > dialog
> >> > window. Use Spy to look at the hierarchy and you'll see what I mean.
It
> >> > appears that the real dialog window (which I assume does get the
> > message)
> >> > examines the various messages and decides to whom it should pass on
> >> > messages.
> >> >
> >> > But that's just off the top of my head.
> >> >
> >> >
> >> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
> >> > news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
> >> >> Hello, I have a CFileDialog derived class.
> >> >> I want to handle the backspace key down in my derived class.
> >> >> I added PreTranslateMessage handler to my class but it never gets in
> >> >> there
> >> >> (Why?).
> >> >> What can I do in order to handle the Back_Space key down in my
derived
> >> >> class?
> >> >> Thanks,
> >> >> Janiv Ratson.
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>


0
kma1 (58)
8/11/2005 9:03:42 AM
Well, it's a bit involved. Best bet is to Google Paul DiLascia CFileDialog
etc. He wrote a good explanation of how to customise the common dialogs.

"Janiv Ratson" <janiv@aoe6.net> wrote in message
news:OU4y0TlnFHA.2580@TK2MSFTNGP09.phx.gbl...
> Thanks,
> How do I hook this window to get the messages?
> Thanks,
> Janiv Ratson.
>
> "KMA" <kma@chum.com> wrote in message
news:ddf49f$f9b$1@atlas.ip-plus.net...
> > Alright. Use Spy to find out who gets the keydown message. I assume it's
> > the
> > listctrl, or rather that the listctrl must have focus for this
> > functionality
> > to happen.
> >
> > Then you need to hook this window/ctrl in order to intercept the
> > WM_KEYDOWNs. When you get VK_BACK as an input paramter you need to
fugure
> > if
> > the user is allowed to go up one dir and either call the default
> > functionality or not accordingly.
> >
> > Do bear in mind that the listctrl is held within a container, so to
locate
> > it you have to do a bit of jiggery pokkery through the dialog
hieracrchy,
> > but Spy will show you where it is.
> >
> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
> > news:uElSwGlnFHA.3408@tk2msftngp13.phx.gbl...
> >> Hello and thanks,
> >> I tried that, but the OnFolderChange notification is sent to me after
the
> >> folder has changed, and I want to prevent the change of the directory.
> >> Thanks,
> >> Janiv Ratson.
> >>
> >> "KMA" <kma@chum.com> wrote in message
> > news:ddeuvh$eud$1@atlas.ip-plus.net...
> >> > Janiv,
> >> >
> >> > Then you could be in luck. The real parent dialog does send some
useful
> >> > messages to your class, one of which is overriden as OnFolderChange.
At
> >> > least in this handler you get to find out when the user has tried to
> >> > change
> >> > folder. I guess you can trap this and take action to prevent access
to
> >> > particular folders. I haven't actually tested this.
> >> >
> >> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
> >> > news:Oi9MqCknFHA.708@TK2MSFTNGP09.phx.gbl...
> >> >> Hello and thanks,
> >> >> I'll try to explain myself better.
> >> >>
> >> >> If you'll open a windows standard File Dialog and set the focus on
the
> >> >> listcontrol(where the folders and files are shown), and than you
press
> >> >> the
> >> >> Back_Space button, the list control will change directory to the
> >> >> parent
> >> > one,
> >> >> another press on the Backspace button will again take you to the
> >> >> parent
> >> >> directory and so on.
> >> >> What I want to do in my derived CFileDialog is to enable the user to
> >> >> go
> >> >> up
> >> >> one level(directory), until a specific directory, Hence limit the
user
> >> >> capability to go to up level until the root directory.
> >> >> I want to limit the user directories to choose a file from.
> >> >>
> >> >> I hope it is clear enough.
> >> >> Thanks,
> >> >> Janiv Ratson.
> >> >>
> >> >>
> >> >> "KMA" <kma@chum.com> wrote in message
> >> > news:ddeooo$eh8$1@atlas.ip-plus.net...
> >> >> > Just off the top of my head, I'm assuming that you added the
handler
> > in
> >> >> > your
> >> >> > CMyFileDialog class.
> >> >> >
> >> >> > I suspect the nub of the probem lies in the fact that your class
is
> > not
> >> >> > the
> >> >> > hierarchical parent of the dialog that you see on the screen. To
put
> > it
> >> >> > another way, your class actually becomes a child of the file open
> >> >> > dialog
> >> >> > window. Use Spy to look at the hierarchy and you'll see what I
mean.
> > It
> >> >> > appears that the real dialog window (which I assume does get the
> >> > message)
> >> >> > examines the various messages and decides to whom it should pass
on
> >> >> > messages.
> >> >> >
> >> >> > But that's just off the top of my head.
> >> >> >
> >> >> >
> >> >> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
> >> >> > news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
> >> >> >> Hello, I have a CFileDialog derived class.
> >> >> >> I want to handle the backspace key down in my derived class.
> >> >> >> I added PreTranslateMessage handler to my class but it never gets
> >> >> >> in
> >> >> >> there
> >> >> >> (Why?).
> >> >> >> What can I do in order to handle the Back_Space key down in my
> > derived
> >> >> >> class?
> >> >> >> Thanks,
> >> >> >> Janiv Ratson.
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>


0
kma1 (58)
8/11/2005 9:30:48 AM
Hello and thanks,
I tried that, but the OnFolderChange notification is sent to me after the 
folder has changed, and I want to prevent the change of the directory.
Thanks,
Janiv Ratson.

"KMA" <kma@chum.com> wrote in message news:ddeuvh$eud$1@atlas.ip-plus.net...
> Janiv,
>
> Then you could be in luck. The real parent dialog does send some useful
> messages to your class, one of which is overriden as OnFolderChange. At
> least in this handler you get to find out when the user has tried to 
> change
> folder. I guess you can trap this and take action to prevent access to
> particular folders. I haven't actually tested this.
>
> "Janiv Ratson" <janiv@aoe6.net> wrote in message
> news:Oi9MqCknFHA.708@TK2MSFTNGP09.phx.gbl...
>> Hello and thanks,
>> I'll try to explain myself better.
>>
>> If you'll open a windows standard File Dialog and set the focus on the
>> listcontrol(where the folders and files are shown), and than you press 
>> the
>> Back_Space button, the list control will change directory to the parent
> one,
>> another press on the Backspace button will again take you to the parent
>> directory and so on.
>> What I want to do in my derived CFileDialog is to enable the user to go 
>> up
>> one level(directory), until a specific directory, Hence limit the user
>> capability to go to up level until the root directory.
>> I want to limit the user directories to choose a file from.
>>
>> I hope it is clear enough.
>> Thanks,
>> Janiv Ratson.
>>
>>
>> "KMA" <kma@chum.com> wrote in message
> news:ddeooo$eh8$1@atlas.ip-plus.net...
>> > Just off the top of my head, I'm assuming that you added the handler in
>> > your
>> > CMyFileDialog class.
>> >
>> > I suspect the nub of the probem lies in the fact that your class is not
>> > the
>> > hierarchical parent of the dialog that you see on the screen. To put it
>> > another way, your class actually becomes a child of the file open 
>> > dialog
>> > window. Use Spy to look at the hierarchy and you'll see what I mean. It
>> > appears that the real dialog window (which I assume does get the
> message)
>> > examines the various messages and decides to whom it should pass on
>> > messages.
>> >
>> > But that's just off the top of my head.
>> >
>> >
>> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
>> > news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
>> >> Hello, I have a CFileDialog derived class.
>> >> I want to handle the backspace key down in my derived class.
>> >> I added PreTranslateMessage handler to my class but it never gets in
>> >> there
>> >> (Why?).
>> >> What can I do in order to handle the Back_Space key down in my derived
>> >> class?
>> >> Thanks,
>> >> Janiv Ratson.
>> >>
>> >>
>> >
>> >
>>
>>
>
> 


0
janiv (189)
8/11/2005 9:46:48 AM
Thanks,
How do I hook this window to get the messages?
Thanks,
Janiv Ratson.

"KMA" <kma@chum.com> wrote in message news:ddf49f$f9b$1@atlas.ip-plus.net...
> Alright. Use Spy to find out who gets the keydown message. I assume it's 
> the
> listctrl, or rather that the listctrl must have focus for this 
> functionality
> to happen.
>
> Then you need to hook this window/ctrl in order to intercept the
> WM_KEYDOWNs. When you get VK_BACK as an input paramter you need to fugure 
> if
> the user is allowed to go up one dir and either call the default
> functionality or not accordingly.
>
> Do bear in mind that the listctrl is held within a container, so to locate
> it you have to do a bit of jiggery pokkery through the dialog hieracrchy,
> but Spy will show you where it is.
>
> "Janiv Ratson" <janiv@aoe6.net> wrote in message
> news:uElSwGlnFHA.3408@tk2msftngp13.phx.gbl...
>> Hello and thanks,
>> I tried that, but the OnFolderChange notification is sent to me after the
>> folder has changed, and I want to prevent the change of the directory.
>> Thanks,
>> Janiv Ratson.
>>
>> "KMA" <kma@chum.com> wrote in message
> news:ddeuvh$eud$1@atlas.ip-plus.net...
>> > Janiv,
>> >
>> > Then you could be in luck. The real parent dialog does send some useful
>> > messages to your class, one of which is overriden as OnFolderChange. At
>> > least in this handler you get to find out when the user has tried to
>> > change
>> > folder. I guess you can trap this and take action to prevent access to
>> > particular folders. I haven't actually tested this.
>> >
>> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
>> > news:Oi9MqCknFHA.708@TK2MSFTNGP09.phx.gbl...
>> >> Hello and thanks,
>> >> I'll try to explain myself better.
>> >>
>> >> If you'll open a windows standard File Dialog and set the focus on the
>> >> listcontrol(where the folders and files are shown), and than you press
>> >> the
>> >> Back_Space button, the list control will change directory to the 
>> >> parent
>> > one,
>> >> another press on the Backspace button will again take you to the 
>> >> parent
>> >> directory and so on.
>> >> What I want to do in my derived CFileDialog is to enable the user to 
>> >> go
>> >> up
>> >> one level(directory), until a specific directory, Hence limit the user
>> >> capability to go to up level until the root directory.
>> >> I want to limit the user directories to choose a file from.
>> >>
>> >> I hope it is clear enough.
>> >> Thanks,
>> >> Janiv Ratson.
>> >>
>> >>
>> >> "KMA" <kma@chum.com> wrote in message
>> > news:ddeooo$eh8$1@atlas.ip-plus.net...
>> >> > Just off the top of my head, I'm assuming that you added the handler
> in
>> >> > your
>> >> > CMyFileDialog class.
>> >> >
>> >> > I suspect the nub of the probem lies in the fact that your class is
> not
>> >> > the
>> >> > hierarchical parent of the dialog that you see on the screen. To put
> it
>> >> > another way, your class actually becomes a child of the file open
>> >> > dialog
>> >> > window. Use Spy to look at the hierarchy and you'll see what I mean.
> It
>> >> > appears that the real dialog window (which I assume does get the
>> > message)
>> >> > examines the various messages and decides to whom it should pass on
>> >> > messages.
>> >> >
>> >> > But that's just off the top of my head.
>> >> >
>> >> >
>> >> > "Janiv Ratson" <janiv@aoe6.net> wrote in message
>> >> > news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
>> >> >> Hello, I have a CFileDialog derived class.
>> >> >> I want to handle the backspace key down in my derived class.
>> >> >> I added PreTranslateMessage handler to my class but it never gets 
>> >> >> in
>> >> >> there
>> >> >> (Why?).
>> >> >> What can I do in order to handle the Back_Space key down in my
> derived
>> >> >> class?
>> >> >> Thanks,
>> >> >> Janiv Ratson.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
> 


0
janiv (189)
8/11/2005 10:10:11 AM
There are different ways to change the current folder in that dialog, and 
baskspace doesn't cover them.

You may have better luck with SHBrowseForFolder, in the mode when it display 
files. You can set a tree root for that dialog.

"Janiv Ratson" <janiv@aoe6.net> wrote in message 
news:Oi9MqCknFHA.708@TK2MSFTNGP09.phx.gbl...
> Hello and thanks,
> I'll try to explain myself better.
>
> If you'll open a windows standard File Dialog and set the focus on the 
> listcontrol(where the folders and files are shown), and than you press the 
> Back_Space button, the list control will change directory to the parent 
> one, another press on the Backspace button will again take you to the 
> parent directory and so on.
> What I want to do in my derived CFileDialog is to enable the user to go up 
> one level(directory), until a specific directory, Hence limit the user 
> capability to go to up level until the root directory.
> I want to limit the user directories to choose a file from.
>
> I hope it is clear enough.
> Thanks,
> Janiv Ratson.
>
>
> "KMA" <kma@chum.com> wrote in message 
> news:ddeooo$eh8$1@atlas.ip-plus.net...
>> Just off the top of my head, I'm assuming that you added the handler in 
>> your
>> CMyFileDialog class.
>>
>> I suspect the nub of the probem lies in the fact that your class is not 
>> the
>> hierarchical parent of the dialog that you see on the screen. To put it
>> another way, your class actually becomes a child of the file open dialog
>> window. Use Spy to look at the hierarchy and you'll see what I mean. It
>> appears that the real dialog window (which I assume does get the message)
>> examines the various messages and decides to whom it should pass on
>> messages.
>>
>> But that's just off the top of my head.
>>
>>
>> "Janiv Ratson" <janiv@aoe6.net> wrote in message
>> news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
>>> Hello, I have a CFileDialog derived class.
>>> I want to handle the backspace key down in my derived class.
>>> I added PreTranslateMessage handler to my class but it never gets in 
>>> there
>>> (Why?).
>>> What can I do in order to handle the Back_Space key down in my derived
>>> class?
>>> Thanks,
>>> Janiv Ratson.
>>>
>>>
>>
>>
>
> 


0
alegr (1131)
8/12/2005 2:09:35 PM
The back space button command changes folder one level up in CFileDialog.
This is what I want to change.
I want that back space will do some special behavior (I wanna override the 
back space handle).
Thanks,
Janiv Ratson

"Alexander Grigoriev" <alegr@earthlink.net> wrote in message 
news:%230NK7d0nFHA.3256@TK2MSFTNGP12.phx.gbl...
> There are different ways to change the current folder in that dialog, and 
> baskspace doesn't cover them.
>
> You may have better luck with SHBrowseForFolder, in the mode when it 
> display files. You can set a tree root for that dialog.
>
> "Janiv Ratson" <janiv@aoe6.net> wrote in message 
> news:Oi9MqCknFHA.708@TK2MSFTNGP09.phx.gbl...
>> Hello and thanks,
>> I'll try to explain myself better.
>>
>> If you'll open a windows standard File Dialog and set the focus on the 
>> listcontrol(where the folders and files are shown), and than you press 
>> the Back_Space button, the list control will change directory to the 
>> parent one, another press on the Backspace button will again take you to 
>> the parent directory and so on.
>> What I want to do in my derived CFileDialog is to enable the user to go 
>> up one level(directory), until a specific directory, Hence limit the user 
>> capability to go to up level until the root directory.
>> I want to limit the user directories to choose a file from.
>>
>> I hope it is clear enough.
>> Thanks,
>> Janiv Ratson.
>>
>>
>> "KMA" <kma@chum.com> wrote in message 
>> news:ddeooo$eh8$1@atlas.ip-plus.net...
>>> Just off the top of my head, I'm assuming that you added the handler in 
>>> your
>>> CMyFileDialog class.
>>>
>>> I suspect the nub of the probem lies in the fact that your class is not 
>>> the
>>> hierarchical parent of the dialog that you see on the screen. To put it
>>> another way, your class actually becomes a child of the file open dialog
>>> window. Use Spy to look at the hierarchy and you'll see what I mean. It
>>> appears that the real dialog window (which I assume does get the 
>>> message)
>>> examines the various messages and decides to whom it should pass on
>>> messages.
>>>
>>> But that's just off the top of my head.
>>>
>>>
>>> "Janiv Ratson" <janiv@aoe6.net> wrote in message
>>> news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
>>>> Hello, I have a CFileDialog derived class.
>>>> I want to handle the backspace key down in my derived class.
>>>> I added PreTranslateMessage handler to my class but it never gets in 
>>>> there
>>>> (Why?).
>>>> What can I do in order to handle the Back_Space key down in my derived
>>>> class?
>>>> Thanks,
>>>> Janiv Ratson.
>>>>
>>>>
>>>
>>>
>>
>>
>
> 


0
janiv (189)
8/14/2005 7:53:59 AM
The Solution:

extern HINSTANCE ghConfigToolCommonInstance; //the dll instance

LRESULT CALLBACK MyOwnMessageProc( int code,       // hook code
          WPARAM wParam,  // not used
          LPARAM lParam)   // message data
{
 if (code == MSGF_DIALOGBOX)
 {
  MSG *pmsg = (MSG*)lParam;

  switch (pmsg->message)
  {
  case WM_KEYDOWN:
    if(pmsg->wParam == VK_BACK)
    {
     TRACE(_T("Backspace is pressed!\n"));
     return 1; //Do not process Message
    }
    break;
  }

 }
  return 0;
}

CDerivedFileDialog::OnInitDialog:
SetWindowsHookEx(WH_SYSMSGFILTER,MyOwnMessageProc,ghConfigToolCommonInstance,0);



"Janiv Ratson" <janiv@aoe6.net> wrote in message 
news:eEU9Q1bnFHA.1416@TK2MSFTNGP09.phx.gbl...
> Hello, I have a CFileDialog derived class.
> I want to handle the backspace key down in my derived class.
> I added PreTranslateMessage handler to my class but it never gets in there 
> (Why?).
> What can I do in order to handle the Back_Space key down in my derived 
> class?
> Thanks,
> Janiv Ratson.
>
> 


0
janiv (189)
9/5/2005 9:27:45 AM
Reply:

Similar Artilces:

ID of CFileDialog
Hi all, i am trying to find Resource ID of CFileDialog, what number is it? i can know this? Let me know if you can help me. Thanks Duy It is not a resource in your project. The dialog is created by Windows when you call GetOpenFileName / GetSaveFileName. -- Sheng Jiang Microsoft MVP in VC++ "James Duy Trinh" <vietdoor@gmail.com> wrote in message news:eOrRoVReIHA.1212@TK2MSFTNGP05.phx.gbl... > Hi all, > > i am trying to find Resource ID of CFileDialog, what number is it? i can > know this? > > Let me know if you can help me. Thanks > > Duy > ...

Crash using CFileDialog
Hi I am using VS6, SP6, XP-SP1 using MFC as dynamic DLL. I am having a crash when using CFileDialog. Searching net revealed that there is a bug in CFiledialog, but that was fixed in SP6. Crash occurs in destructor of CFileDialog. Can you please guide me to some quick Fix. -- Best regards Shrishail Rana Was the class used as a base class in another class? How did you initalize the CFileDialog class? Directly as ususal. The same code was working properly when MFC was used as static link library. -- Best regards Shrishail Rana CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDERE...

CFileDialog
Windows 7 has changed the rules for the member lpstrInitialDir of CFileDialog to: 1. If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory. I want to be able to set the path to what I want not what the first time it was used was. Is there a way to do this? Thank you, Tim ...

opening CFileDialog from modeless or creating modeless CFileDialog
Hey everyone, got a quick questions again as I went and messed up my MFC app and now can't seem to find a solution to my problem. My Old program was simply 1 modal dialog box (call it EDITOR) and when the user clicked "open" it called CFileDialog (of course domodal()) and everything worked fine. Now however I have a different dialog box as the modal, which in turn CREATEs (modeless :) my EDITOR. (This so far of course works fine). However whenever I click on the "open" button the program immediately crashes (bringing up dbgrpt.c) basically telling me that the CFile:...

Problem with CFileDialog
CFileDialog is extremely slow on windows xp when trying to view files in a directory with as few files as a 1000 over a network. The File Dialog box opens and hangs with the hour glass icon blinking for as long as 6 mins before displaying a view of selectable files. This doesn't seem to be such a problem under Windows NT 4. Any help would be greatly appreciated thanks John. Good news : We too had the same problem (XP) - not even across a network !. Bad news : We couldn't fix it either :-( What appears to be happening is that accessing a directory, XP insists on caching t...

UNICODE bug in CFileDialog?
Hi some methods in CFileDialog take an LPCSTR parameter where I think it should be LPCTSTR I'm sure it's a bug in SetControlText. I suspect it is one in SetDefExt Can anyone confirm this Thn HS GetFileTitle(...) in CFileDialog supports UNICODE and all the other methods are not UNICODE supported. See the AFXDLGS.H declarations. Cheers Jagadeesh "HS" <anonymous@discussions.microsoft.com> wrote in message news:6E8FCC2B-D79A-4B46-8D86-9829BF332525@microsoft.com... > Hi, > > some methods in CFileDialog take an LPCSTR parameter where I think it should be LPCTST...

A CFileDialog Question
Hello,everyone. I have encountered a problem about CFileDialog tonight. First, i create a CFileDialog instance and run it(Do Modal). Then,i select a folder and press button Ok. Now i want to get the path of the folder i selected. So I hope to use the function GetFolderPath,but error have occured . I don't Know what's wrong! Who can tell me? ? How can I get the folder Path from CFileDialog? ? ? Thx for your replies! ! ! ! ! You will need to use a folder browser (SHBrowseForFolder) like: http://www.codeproject.com/dialog/XBrowseForFolder.asp Tom "xhy_China&q...

CFileDialog.
Hi, I would like to create a button which can get the path from a drive after clicking the button. I am thinking to use CFileDialog box with the "open" option. However, I cannot get out of the file dialog box until I select a file. If I only want to select a path, and get out of the dialog, do I need to derive a class from CFileDialog class? Thanks. Leo Is this the current drive or are you asking the user to select a path? If it's the latter, use SHBrowseForFolder, if you just want the current drive use getdrive. HTH -- ============ Frank Hickman NobleSoft, Inc. ==...

ListView style of CFileDialog
Hi, How can I find out what the ListView style (e.g. Thumbnails) is of a CFileDialog just before I close it? Richard "Richard" <richi_8@hotmail.com> ha scritto nel messaggio news:mn.930c7d776e765651.0@hotmail.com... > Hi, > > How can I find out what the ListView style (e.g. Thumbnails) is of a > CFileDialog just before I close it? I think you might find the following articles interesting: http://www.codeproject.com/dialog/customize_dialog.asp http://msdn2.microsoft.com/en-us/library/ms996463.aspx http://www.codeproject.com/dialog/FileDialogEx.asp G ...

Problem with CFileDialog #2
Hello, I have a CFileDialog with multiple selection and open mode, when I select the files with click on the first one then shift+click on the last one and close the dialog with “Open” button, DoModal() returns IDCANCEL!!!, but when I select the files with Ctrl+Click it works fine. I work with VC6.00 and Windows 2000. This is my code: void COrgDocTemplatesDlg::OnBtnSelect() { CFileDialog dlg( TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_EXPLORER |OFN_ALLOWMULTISELECT|OFN_PATHMUSTEXIST, NULL, this); if( dlg.DoModal() != IDOK ) return; POSITION pos = dlg.GetStartPosi...

About CFileDialog
Dear all, I have a strange problem about CFileDialog. I have created a project which can save some words to text file. The user can select the save path and save name in CFileDialog. I am using Chinese window and all the things is perfect. However, when I build the project and copy the .exe file to a Japanese window to test, the saved file name is not as same as the name which the user selected. For example, A wants to save the words to a.txt, however, the CFileDialog return the adoru.txt file name to the project. Therefore, I want to know why this happen and how can I solve it. Thank...

Deriving From CFileDialog
I am deriving a class from CFileDialog so I can add a little more functionality. I used the following steps: 1) Created a new dialog box with a group box in it. 2) Set the group box ID to stc32=0x045f 3) Added m_ofn.Flags |= OFN_ENABLETEMPLATE; ...

CFileDialog problem
I added a CFileDialog (VC6 on a XP machine) to an existing project, using it in a very simple way: CFileDialog FileDlg(TRUE, NULL, NULL, OFN_EXPLORER, "All Files (*.*)| *.*|Image files (*.img)|*.img||" ); if (FileDlg.DoModal() == IDCANCEL) return; The file open dialog box appears, showing all files *.* in the current folder. So far so good and as expected. The problem occurs when selecting the file type option *.img: From now on the file list stays empty, even when returning to *.*. The same code in a freshly created project on the same machine works perfectly. Any idea about the...

Customize CFileDialog
Hello I have a customized CFileDialog, It works very well, but I wanted to get the change event from the edit control that maintain the filename (cmb13). I tried ON_EN_CHANGE(cmb13,OnFileNameChanged) but I'm not receiving any event.I'm wonder if there are any way to receive it. Thanks ...

Keyboard Messages not intercepted when PreTranslateMessage is used
Hi Mine is a MFC ActiveX Ctrl. I am using PreTranslateMessage as follows so that keystrokes like backspace can be detected in IE, but though SendMessage gets called, the Keystrokes like Arrow keys, delete backspace don't function at all in ActiveX container as well as IE. Am I missing something or do I need to explicitly write WM_KEYDOWN (KEYUP) message handlers? Please let me know. BOOL CMegafleetPluginCtrl::PreTranslateMessage(MSG* pMsg) { switch (pMsg->message) { case WM_KEYDOWN: case WM_KEYUP: switch (pMsg->wParam) { c...

Using CFileDialog?
I am using three different file types in my File Dialog. Now when the User types in a file name and select a particular file type from the drop down box and tries saving it, it doesn't save the file type selection from the drop down box. And also when i tried to get the file extension using the GetFileExt() function it doesn't work. Unless user types the file extension along the file name, this function is not able to retrieve the file extension. How can this be resolved? Thanks in advance. OK, what do you mean by "save"? Do you mean that the NEXT time you use the CFile...

refreshing CFileDialog programatically
Hello, I have derived the CFileDialog, named CCustomFileDlg. I need a special functionality. I added an "Import" button the the dialog, it opens a regular CFileDialog, and the user choses a file. The file is added to the same place where the open directory in my CCustomFileDlg. The problem is that I want to select the added file. I did the following (this code is after the copying process): CWnd* pWndList = GetParent()->GetDlgItem(lst2); CListCtrl* pList = (CListCtrl*)(pWndList->GetDlgItem(1)); int iCount = pList->GetItemCount(); I get the number of items before the copy...

Modifying CFileDialog
Hello, I wanna inherit from CFileDialog and make some changes to the built in controls. e.g., I wanna under some conditions to disable the "Go Up Level" button, and some more crazy ideas. How do I do it ? Thanks, Nir. On Thu, 8 Apr 2004 14:55:16 +0200, "Nir Schwartz" <nirsc@hotmail.com> wrote: >Hello, > >I wanna inherit from CFileDialog and make some changes to the built in >controls. >e.g., I wanna under some conditions to disable the "Go Up Level" button, and >some more crazy ideas. >How do I do it ? Derive your class from it Ad...

Using CFileDialog
Hi all, I am trying to get the selected folder and no files just like adding include folder in VS.Net~~ view no files except folder ~~ fdlg.m_pOFN->lpstrFilter = ? fdlg.m_pOFN->Flags |= ? thanks advance~ >I am trying to get the selected folder and no files Try using SHBrowseForFolder instead. Dave ...

Use of CFileDialog
I'm trying to use CFileDialog to allow the user to select an existing file, but it asserts in DoModal because (m_ofn.Flags & OFN_ENABLEHOOK) is ok. If I set that flag, it'll assert because (m_ofn.lpfnHook != NULL) is false. I didn't think I needed to provide a hook function. If I do, how should I provide it and what should it do? If I bypass those two asserts, the dialog comes up but displays no files. Have I created the filter string incorrectly? Finally, it dies with an access violation in the destructor. I'm guessing this will stop if I fix the other two issues. I'...

Filters and CFileDialog
Hi, I've been trying a number of suggestions about filters in the MFC File Open dialog, but I just can't seem to get them to work. I can get the default "*.*" filter to work all right, but not my own file extension. What am I doing wrong: CString strFilter = _T("Fun Functions (*.fun)\x0*.fun\x0\x0"); CFileDialog dlgBrowse(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ENABLESIZING); dlgBrowse.m_ofn.lpstrTitle = "Open a Fun Function"; dlgBrowse.m_ofn.lpstrFilter = strFilter; if (dlgBrowse.DoModal() == IDOK) { AfxMessageBox(_T("F...

CFileDialog problems
Im working on a project (using VC7) and im having problems getting the CFileDialog class to function correctly. Im using the dialog to load and save XML files. However, whenever the filter drop-down button is changed from XML (*.xml) files to all files (*.*) the list off files in the window disappear altogether. Im sure this is a bug with CFileDialog as Ive tried code from MSDN and still have the same results. A simplified version of the code im using is: // XML Files (*.xml)|*.XML|All Documents (*.*)|*.*|| CString csFilter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*||"; CFil...

CFileDialog::OnSizing()
I've derived a class from CFileDialog and want to intercept the OnSizing function. Problem is, how ? I can over-ride it via class wizard but the resulting function never gets called. (I've also over-ridden OnSize() and that works fine). Any suggestions ? TTFN, Jon =?Utf-8?B?Sm9uIEV2YW5z?= <JonEvans@discussions.microsoft.com> wrote in news:739DD54A-B81B-45F8-B227-1C9577A1E55C@microsoft.com: > I've derived a class from CFileDialog and want to intercept the OnSizing > function. > > Problem is, how ? I can over-ride it via class wizard but the resulting ...

Extending CFileDialog
I'm trying to extend CFileDialog in the following way: I have a group of project-specific files which are stored together in a project folder, where the project folder has a distinguishable name, e.g. via an extension, etc. When the user browses to such a folder, I can infer from context which project file the user is trying to load, and would therefore like to pick that file and return IDOK from DoModal. I have overridden OnFolderChange in the following way: void MyFileDialog::OnFolderChange ( ) { bool is_project_folder = // logic to see if folder name contains project folder n...

CFileDialog #3
How I can set my text for Sample text in CFileDialog? Tnx. Zizo wrote: > How I can set my text for Sample text in CFileDialog? > > Tnx. Sorry, CFontDialog.. :-) I haven't presonally tried using this but it might be a good start. http://codeguru.com/dialog/font_dialog.shtml Ali R. "Zizo" <zizo@zz.com> wrote in message news:bqi3em$58l$1@ls219.htnet.hr... > How I can set my text for Sample text in CFileDialog? > > Tnx. > > ...