|
Basically, MFC is quit strong to handle all this things enternally, you only need to do is that give same ID to toolbar and menubar item.
Like,
If you have PQR.bmp on ID_CLICK_ME toolbar then give ID_CLICK_ME to menu bar item so it directly taken POR.bmp as menubar bitmap.
|
|
|
|
|
Thanks For your Reply.
Actually , I am giving toolbar single bmp name to MenuItem.
For Example. ToolBar name is IDR_TOOLBAR1 which consist of images whose names are ID_FILE_NEW,ID_FILE_OPEN.
And Under Menu IDR_MENU1 have menuItems New,Open with ID ID_FILE_NEW and ID_FILE_OPEN same as in toolbar bmp.
And Used same LoadImage function to load Icon but returning NULL.
Or am I doing something Wrong?
Regards
y
|
|
|
|
|
why are you not trying this??
CImage image;
image.Load(_T("C:\\image.png")); CBitmap bitmap;
bitmap.Attach(image.Detach());
|
|
|
|
|
If I try this way then I have to load each and every image for Menuitems again single by single.
I am looking for a way to use from Toolbar bmp into MenuItems Icons.
So,only I am accessing over resources by name to match with same menuitem Icon.
Anyway,thanks For ideas. But ,better if I use from toolbar bmp.
Y
|
|
|
|
|
The new CMFCMenuBar class already does this for you.
To use this class you will need Visual Studio 2008 with Feature pack or VS 2010 and later.
|
|
|
|
|
How Can I use CMFCMenuBar to load Images from Toolbar. As I am already using CMenu.
Do I need to get CMFCMenubar object OnInitmenuPopup? or Some other way .
I am confused about using CMFCMenubar.
Regards
Y
|
|
|
|
|
Another solution you can find here[^] ....
|
|
|
|
|
Thanks Flaviu2 But I saw this Post already. here it is just conversion from ICon to bitmap. And My problem is to first Find out the Icons from Resources by name from either toolbar bmp .
|
|
|
|
|
Hello all,
I have a MFC app being developed on VS 6.0
I added code to dynamically change the size of the dialog when a check box is checked. i.e., it hides some controls and then resizes the dialog to show only less controls.
And this works fine in one display setting. And i am running it on Windows 7 and mydisplay is Medium - 125%
If i go to display settings and change the type to Smaller - 100% or Larger - 150%, then resizing completely screws up and some controls are not shown at all.
I figured that with change in display setting the resizing takes the controls to different positions that it goes out of scope of dialog.
Is there a way around? Any way of locking the controls irrespective of change in display settings?
Thanks in advance.
|
|
|
|
|
|
When i try to call SetProcessDPIAware from inside the InitInstance fucntion of the app, it says the fucntion - error C2065: 'SetProcessDPIAware' : undeclared identifier
Why is it so?
Btw, this is a MFC app being developed in Visual Studio 6.
Is there a different way to set it DIPaware?
|
|
|
|
|
The API is only supported from Windows Vista and above.
So you need to define the following macros as below -
_WIN32_WINNT = 0x0600
WINVER = 0x0600
|
|
|
|
|
Hi, I created a dialog based MFC smart device project, I found 2 dialog resources in dialog folder of resource view. one is
IDD_xxx_DIALOG; another is IDD_xxx_DIALOG_WIDE.
Anybody can tell me why VS create 2 dialogs?
And carelessly, I put some controls in IDD_xxx_DIALOG_WIDE, I found in the property view of the control, when I cliked event icon, the event view was empty.
|
|
|
|
|
See if this helps.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
In a dialog I had replaced an CListBox with CListCtrl ... the old CListBox had used SetItemDataPtr, to store a CMyObjects pointers ... but CListCtrl does not have not such a thing (CListCtrl::SetItemDataPtr, only CListCtrl::SetItemData) ... how can I store an object pointers into CListCtrl ? Is it posible ?
modified 2-May-13 8:57am.
|
|
|
|
|
You can store 'pointers' with SetItemData() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Pass the pointer value to SetItemData by type casting it to DWORD_PTR .
When reading it back you will need to type cast it back to the original pointer type.
|
|
|
|
|
Thank you so much for your answers (both of you), I will try that right away and tell you what I've done ... but it came into my mind a question ... if I could store pointers into SetItemData(...) , why CListBox does have SetItemData and SetItemDataPtr ... it is not a kind of redundancy ?
|
|
|
|
|
Flaviu2 wrote: but it came into my mind a question ... if I could store pointers into SetItemData(...) , why CListBox does have SetItemData and SetItemDataPtr ... it is not a kind of redundancy ? Doesn't SetItemDataPtr() internally cast and call SetItemData() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I think that you are right ... thanks !
|
|
|
|
|
Does function well ... Thanks !
|
|
|
|
|
Dear All,
I'm new to C++\ MFC so I hope my questions are easy to answer.
I tried to add a user defined message-handler to an CDialog derived class by adding the following:
1. defining a message
#define WM_UPDATE_UI WM_USER+1
2. declare method
afx_msg LRESULT OnUpdateUI(WPARAM wParam,LPARAM lParam);
3. extend message map
BEGIN_MESSAGE_MAP(CMyDialog,CDialog)
...
ON_MESSAGE(WM_UPDATE_UI,&CMyDialog::OnUpdateUI)
END_MESSAGE_MAP
4. handle message
LRESULT CMyDialog::OnUpdateUI(WPARAM wParam,LPARAM lParam)
{
return 0;
}
Because of the message map entry i recieve the 14 errors:
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(33) : error C2143: syntax error : missing '}' before ';'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(33) : error C2143: syntax error : missing '}' before ';'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(33) : error C2143: syntax error : missing ';' before ','
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(33) : error C2059: syntax error : ','
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2143: syntax error : missing ';' before '{'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2447: '{' : missing function header (old-style formal list?)
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2059: syntax error : '}'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2653: 'TheBaseClass' : is not a class or namespace name
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2065: 'GetThisMessageMap' : undeclared identifier
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2065: '_messageEntries' : undeclared identifier
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2059: syntax error : 'return'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(34) : error C2059: syntax error : '}'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(40) : error C2143: syntax error : missing ';' before '{'
2>e:\projects\dummyactivex\dummyactivex\mydialog.cpp(40) : error C2447: '{' : missing function header (old-style formal list?)
I really don't know the error, please help!
Thanks in Advanced.
|
|
|
|
|
I can't see anything seriously wrong in the posted code. So the error may be also somewhere else (probably in a line before number 33 in mydialog.cpp). A possible error source is forgetting the trailing semicolon after the class declaration:
class CMyDialog : public CDialog
{
};
I have some more notes:
You should always use parentheses with definitions and macros:
#define WM_UPDATE_UI (WM_USER+1)
The afx_msg prefix is not necessary:
LRESULT OnUpdateUI(WPARAM wParam,LPARAM lParam);
In the message map, just pass the function name:
ON_MESSAGE(WM_UPDATE_UI, OnUpdateUI)
|
|
|
|
|
Oh my goodness!
you're right, it is caused by a semicolon before class definition.
So of course now the error message makes sense.
Sorry for wasting time 
|
|
|
|
|
Thank you for your feedback.
Such mistakes happen (even to me after years of programming). When forgetting the semicolon at the end of a header file, the error is thrown at the first semicolon in the next file which might be another header file or the source file. If you remember this and get such a bulk of messages the next time, you will probably know where to look first.
|
|
|
|