|
|
I'd go with Richard's reply, except instead of SetFocus, I'd use
the WM_NEXTDLGCTL message. WM_NEXTDLGCTL automatically selects the
edit control text so the user can just type if there's existing text.
Of course, if the edit control is empty it does't make a difference
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I am developing a GUI based application using C++ and MFC. I have a couple of menu options
that should be grayed out when the application starts up. What I mean by grayed out is that
they are not valid for the user to select and the visual appearance of the menu option should
reflect that. The menu is defined in an RC (resource script) file. What is the best way to
have these menu selections grayed out?
Thanks
Bob
|
|
|
|
|
Typically, the ON_UPDATE_COMMAND_UI Macro[^] is used to provide a command enabler function.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark or anybody else that knows,
Thanks for the response. However, I am not sure what you are saying. Please consider
the following menu:
Selection 1
Selection a
Selection b
Selection c
Selection d
and the user chose Selection 1, I use then have a function (or method) to gray out
the sub-menu selection that I wanted grayed out. If so, how would the handler do
that?
I was thinking that I might do it when the menu is first created. I world do this by using the macro ON_WM_INITMENUPOPUP. What do you think of my approach?
Bob
|
|
|
|
|
You can set the menu status with this function call:
CMenu::SetMenuItemInfo
|
|
|
|
|
BobInNJ wrote: I am not sure what you are saying
I'm saying typically Selection a, Selection b, etc. each have an associated command
(for example, using the wizards, ID_SELECTION1_SELECTIONA)
IDR_MYMENU MENU
BEGIN
POPUP "Selection 1"
BEGIN
MENUITEM "Selection a", ID_SELECTION1_SELECTIONA
MENUITEM "Selection b", ID_SELECTION1_SELECTIONB
END
END
ON_UPDATE_COMMAND_UI(ID_SELECTION1_SELECTIONA, &CMainFrame::OnUpdateSelection1Selectiona)
...
void CMyMenuWindowFrame::OnUpdateSelection1Selectiona(CCmdUI *pCmdUI)
{
if (some_state)
pCmdUI->Enable(TRUE);
else
pCmdUI->Enable(FALSE);
}
Three advantages of using the command macros are:
1) MFC does the work for you
2) The IDE has wizards to add the command handler and enabler functions with just clicks
3) If you have a toolbar or possibly other context menu(s) with equivalent
commands, you only have to write the enabling code in one place.
That's the MFC way.....you are free to do it manually if you want to.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
Thanks for the detailed response. It solved my problem.
Bob
|
|
|
|
|
Hi! I have a CBrush created with the CBrush(COLORREF crColor) constructor. I'd like to know if I can retrieve this colorref later from the CBrush, or do I have to store it in a variable? Thx
|
|
|
|
|
This method [^] looks promising (see the lbColor member of the LOGBRUSH [^] struct).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
You're welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
Is it possible to enable/allow ActiveX controls inside my webbrowser control (CHtmlView).
Please do not say it is not possible!
Niki
PS: Background: I'm writing a database application where data is stored in html format. There are also popups (similar to the old WinHelp32) which are implemented using JavaScript (or similar things; these scripts are not written by me). When I open such a HTML file directly in IE I get the security warning (even when all files are local). In my webbrowser control I even do not get a warning but only script errors.
|
|
|
|
|
I have found CoInternetSetFeatureEnabled.
But nothing changes
I have already set FEATURE_WEBOC_POPUPMANAGEMENT, FEATURE_SECURITYBAND, FEATURE_LOCALMACHINE_LOCKDOWN, FEATURE_RESTRICT_ACTIVEXINSTALL. But nothing changes
I again get a script error with "Permission denied"
|
|
|
|
|
The problem was not the browser control itself but my async pluggable protocol!
I missed to handle PARSE_SECURE_URL for the secure manager so two different URLs in my protocol were essentially in a different domain.
So I got "permission denied"-messages when accessing different frames (cross frame scripting prevention)
Regards,
Niki
|
|
|
|
|
Hello, I have a problem with static variables and inheritance
<br />
<br />
class BVolume {<br />
protected:<br />
enum { NONE = 0, SPHERE, BOX, PLANE };<br />
public:<br />
static const unsigned short type = NONE;<br />
<br />
virtual bool TestCollision(BVolume * volume)=0;<br />
<br />
};<br />
<br />
<br />
<br />
class BBox : public BVolume {<br />
public:<br />
static const unsigned short type = BOX;<br />
<br />
bool TestCollision(BVolume * volume) { return Collision< volume -> type >(volume); }<br />
<br />
template< unsigned short type > bool Collision(BVolume * volume) { return false; }<br />
<br />
template< > bool Collision< BOX >(BVolume * box) { return BoxCollision(static_cast< BBox * >(box)); }<br />
template< > bool Collision< SPHERE >(BVolume * sphere) { return SphereCollision(static_cast< BSphere * >(sphere)); }<br />
<br />
bool BoxCollision(BBox * box) { return true; }
bool SphereCollision(BSphere * box) { return true; }
<br />
<br />
};<br />
<br />
<br />
<br />
BBox b1, b2;<br />
<br />
bool Collided() {<br />
<br />
return b1.TestCollision(&b2);<br />
<br />
}<br />
<br />
if(Collided()) std::cout << "Collided";<br />
else std::cout << "Not Collided";<br />
<br />
the code above outputs "Not Collided"
I found the problem but i don't know how to solve it.
Problem:
volume->type in BBox::TestCollision is NONE (it needs to be BOX or SPHERE here) because static is a Compile Time "Thing". I need something Run Time "Thing".
What can i do? Please Help me with that problem!
Thanks,
Kasya
|
|
|
|
|
Why don't you use a virtual method, for instance getType(), instead of a const?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
please tell me how? Like that:
virtual const unsigned short getType() { return BOX; }
It doesn't work i tested it.
If you mean another thing please tell me.
Thanks,
Kasya
|
|
|
|
|
This works for me:
class BVolume {
public:
enum { NONE = 0, SPHERE, BOX, PLANE };
static const unsigned short type = NONE;
virtual bool TestCollision(BVolume * volume)=0;
virtual const unsigned int getType(){ return NONE;}
};
class BBox : public BVolume {
public:
static const unsigned short type = BOX;
bool TestCollision(BVolume * volume) { return Collision< volume -> type >(volume); }
template< unsigned short type > bool Collision(BVolume * volume) { return false; }
bool BoxCollision(BBox * box) { return true; }
virtual const unsigned int getType(){ return BOX;}
};
void main()
{
BBox b1, b2;
BVolume *pv1 = &b1;
if ( pv1->getType() == BVolume::BOX) cout << "is a box" << endl;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i get error when using this:
bool TestCollision(BoundingVolume * volume) { return Collision< volume->getType() >(volume); }
Error:
error C2975: 'type' : invalid template argument for 'BoundingBox::Collision', expected compile-time constant expression
modified on Sunday, January 4, 2009 12:06 PM
|
|
|
|
|
Why don't you exploit polymorphism instead of using template methods?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Exploit is such a harsh word....I prefer "enslave".
Sorry for the OT interruption
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Sorry for the OT interruption
Oh, I know you wanted sooooooooooooo bad to be the first CP 's member to join the Happy Brigade [^] in 2009.
Welcome Mark!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Wow! I had never heard of that list.
A dubious honor indeed! I am so honored!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|