|
I gave you the link to the documentation, you just need to follow the instructions.
|
|
|
|
|
|
(disclaimer, I've not tried it on a popup menu; only regular menu).
The simplest way is to use CMFCToolBar::AddToolBarForImageCollection.
You create a dummy toolbar with all the images you want to use and call the above static method and the images will automagically be added to the menus.
I'd rather be phishing!
|
|
|
|
|
Can you show me in code if is possible?
|
|
|
|
|
It is quite simple, just create a new toolbar with the images you need (with the same ID as your menu ID).
and call
CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES);
at the end of the "OnCreate" of the mainframe (in case of a MFC document).
Have a look at the C++/MFC samples available on MSDN.
http://www.microsoft.com/en-us/download/details.aspx?id=5718[^]
There are examples of that in the: "VisualStudioDemo", "NewControls" samples. (among others).
I'd rather be phishing!
|
|
|
|
|
I done it!!!!
I did so:
1) OnCreate i put this as you told me:
CMFCToolBar::AddToolBarForImageCollection(IDR_MAINFRAME_256);
2) in Contextmenu i add these lines:
CMFCPopupMenu* PopupMenuFolders = new CMFCPopupMenu();
CheckWhatCanIDo(ExtractFullTreePath(htSelectedTreeItem),MainComputerinfo.szSid,m_bUserAuthorizations);
PopupMenuFolders->InsertItem(CMFCToolBarMenuButton(ID_POPUP_FOLDERS_TREE_1, NULL, 0, _T("Item 1")));
PopupMenuFolders->InsertItem(CMFCToolBarMenuButton(ID_POPUP_FOLDERS_TREE_2, NULL, 1, _T("Item 2")));
PopupMenuFolders->InsertItem(CMFCToolBarMenuButton(ID_POPUP_FOLDERS_TREE_3, NULL, 2, _T("Item 3")));
PopupMenuFolders->Create(this, point.x, point.y, NULL);
So you use directly the Toolbar Images.
Thanks all
Giovanni
|
|
|
|
|
Hello
I'm trying to open the COM Port on a Windows CE Device in C++ but without any success
I'm sure that the port exist and available becaus I can use it from cSharp
To do it with C++ I'm trying to use the CreateFile method
The first issue was that CreateFile needs a LPCWSTR
And as it is a long time that I did'nt work with C++ in Windows I had to find ho to assign a LPCWSTR Pointer
So here is my attempt
But it give an Error 2 during execution
NB : I've also tryed different declaration of the Com port but with the same bad result
wchar_t tt[]=L"COM5";
wchar_t tt[]=L"COM5\0";
wchar_t tt[]=L"COM5:";
wchar_t tt[]=L"COM5:\0";}
I can't believe that there is no way to open the Com port on Win CE in cSharp
Thanks for any help
wchar_t tt[]=L"COM5";
int len=0;
int result=0;
char *buffer;
DWORD dw;
hComm = CreateFile( tt,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
NULL,
NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
dw=GetLastError();
}
|
|
|
|
|
As far as I know, CreateFile 's first argument must be a LPCTSTR .
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Great !
You help me a lot
1- It is LPCTSTR indeed
2- The column is required
This is working
LPCTSTR portname = L"COM5:";
int len=0;
int result=0;
char *buffer;
DWORD dw;
hComm = CreateFile( portname,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
NULL,
NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
dw=GetLastError();
int uu=5;
}
|
|
|
|
|
The correct way to set the LPCTSTR is:
LPCTSRT portname = _T("COM5:");
As far as I know, the column is NOT required.
By the way, you are welcome.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hi,
CPallini wrote: As far as I know, the column is NOT required.
It is required. Alternatively the full device namespace path can be used: "\\\\.\\COM1"
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: It is required
Is it a CE thing or this very MSDN example[^] is wrong?
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
It is quite specific under CE
http://msdn.microsoft.com/en-us/library/aa517318.aspx[^]
Could not be more clear =>
When lpFileName points to a COM port to open, you must include a colon after the name. For example, specify COM1: to open that port. When using IrCOMM, specify COM3:.
In vino veritas
|
|
|
|
|
OK, got it, thank you very much.
By the way: Microsoft, oh my God!
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hi All,
Can anyone plz help me to freeze the first column of a CListView, on horizontal scroll the first column should be freezed and remaining columns should move.
I am using MFC.
Any sample is more appreciated.
Thanks,
SMA
|
|
|
|
|
See here.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
What is a current C ( ANSI C) standard on putting <b>optional</b> parameters / attributes into function?
Or is there such a thing - ANSI standard _ anymore?
"Popular" microprocessor compiler does not allow such thing and "workaround" is function overloading.
Which IMHO in memory limited device adding more similar functions into code does not make much sense, unless you are memory chips salesman.
Cheers Vaclav
|
|
|
|
|
You could get around it by using the main pattern, where the first parameter tells the function how many items are in the array pointed to by the next; i.e.
int function(int count, void** somepointer)
{
}
|
|
|
|
|
ANSI C only provides variable number of arguments, via the va_list, va_start, va_arg, va_end mechanism. See, for instance here[^].
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Thanks, but I may have messed up my question.
What I was looking for - is this syntax ANSI C standard
function(int a, int b = 0)
Where passing the second parameter in function call is optional.
Cheers Vaclav
|
|
|
|
|
|
Now I am totally lost.
I thought overloading was having same function name with different types of variables.
Such as
function(int)
function(void*)
function(double)
That works fine in Arduino C++ compiler.( And right now I have a bug in my code because I am using it).
I am assuming Arduino compiler is C++, did not really try to find out.
But since it works with classes....it must be C++ based.
Cheers Vaclav
|
|
|
|
|
Vaclav_Sal wrote: I thought overloading was having same function name with different types of variables. Such as function(int) function(void*) function(double) You thought right.
Vaclav_Sal wrote: That works fine in Arduino C++ compiler
As it should: after all is a C++ compiler.
You have to understand that C and C++ are two different programming languages. While C++ supports function overloading, C does not.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
The following defintion is implied overloading since you can call it in one of two ways.
function(int a, int b = 0);
function(1, 2);
function(1);
|
|
|
|
|
OK, I did try this
void TestFunctionA (int a, int b = 100)
{
a += 1;
b += 10;
Serial.print(b);
}
void TestFunctionB (int a)
{
a += 1;
// b += 10;
Serial.print(a);
}
and calls
TestFunctionB (10); // int a, int b = 100)
TestFunctionA(10,234);
And the compiler said too many arguments in function call
But if I change the b to float it compiles and it does makes sense to me. Partially.
If the b parameter b is not passed, than the function A will be executed and compiled.
Confusing, yes.
But that was not the reason I asked. In "real" C compiler when a parameter is declared optional the code will compile without having to change all function calls to include the optional parameter.
But I still do not know if that is ANY standard or just MS compiler specific.
But Arduino compiler expects the "optional" parameter, so it is really not optional.
Cheers Vaclav
|
|
|
|