|
You could do your own calibration or have vendor remove dialog box. Failing that, when the calibration utility is started, you could have a thread monitor windows ans when that window pops up, either force it to the foreground or just close it yourself.
Where it gets tricky is that only the current active, foreground application can make another application the foreground and despite appearances, who is this application isn't always straightforward. To get around this for one project, I ended up writing the following (The W is the prefix for my personal, but in-the-public-domain, library:
bool WSetAppToForeground(LPCWSTR pWindowName)
{
HWND hWnd = FindWindow(NULL, pWindowName);
if (!hWnd)
return false;
WSetAppToForeground(hWnd);
return true;
}
void WSetAppToForeground(HWND hWnd, bool showMax, bool setFocus)
{
#ifndef _WIN32_WCE
DWORD foregroundProcessId = GetWindowThreadProcessId(::GetForegroundWindow(), NULL);
DWORD curThreadId = GetCurrentThreadId();
AttachThreadInput(foregroundProcessId, curThreadId, TRUE);
#endif
ShowWindow(hWnd, showMax ? SW_SHOWMAXIMIZED : SW_SHOW);
BringWindowToTop(hWnd);
SetActiveWindow(hWnd);
SetForegroundWindow(hWnd);
if (setFocus)
SetFocus(hWnd);
#ifndef _WIN32_WCE
AttachThreadInput(foregroundProcessId, curThreadId, FALSE);
#endif
}
|
|
|
|
|
Hi i am searching many information about this, but i only find complex code. I simply need a context menu with icons. Now i post my code can you help me to complete?
CMenu Menu;
Menu.CreatePopupMenu();
Menu.AppendMenuW(MF_STRING,ID_POPUP_1,(LPCTSTR)_T("Item 1"));
Menu.AppendMenuW(MF_STRING,ID_POPUP_2,(LPCTSTR)_T("Item 2"));
Menu.AppendMenuW(MF_STRING,ID_POPUP_3,(LPCTSTR)_T("Item 3"));
theApp.GetContextMenuManager()->ShowPopupMenu(Menu, point.x, point.y, this, TRUE);
I have seen on MSDN i have to use this:
ASSERT(m_CheckBitmap.LoadBitmap(IDB_CHECKBITMAP));
ASSERT(m_UnCheckBitmap.LoadBitmap(IDB_UNCHECKBITMAP));
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(4);
ASSERT(submenu->SetMenuItemBitmaps(ID_MENU_BITMAP, MF_BYCOMMAND,
&m_CheckBitmap, &m_UnCheckBitmap));
But i think my situation is more easy than example, but maybe i have problems to merge the two code parts,
please can you help me i don't think take you more time.
Thanks very much.
|
|
|
|
|
According to the documentation[^], the bitmaps are just used to indicate the item is selected or not. The MSDN sample shows you how to add the two bitmaps to your menu items. When you say you just want icons, do you mean without any text? If so you need to look at http://msdn.microsoft.com/en-us/library/kb145b0a.aspx[^], for the options to set up individual menu items.
|
|
|
|
|
I need a popup menu with an icon 16x16 on the left and the text on the right, for every menu item.
|
|
|
|
|
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
|
|
|
|
|