|
Hi!!!
I am currently writing OnContextMenu handler. This is supposed to show Shortcut menus when the user presses Right click.
The menu is coming up right but none of the text shows up. Can someone point me to some example which has implemented this or let me know if you have written this part of UI code?
Thanks in advance.
P.S. Windows API Gui is way too whacked. But once it all comes together it is cool
|
|
|
|
|
Post an example of the code that creates and displays the context menu.
Kuphryn
|
|
|
|
|
HMENU hPopMenu = NULL;
MMMENUITEMINFO lpCoolMenuItemInfo, lpCoolMenuItemInfo1;
if (!hPopMenu) hPopMenu = ::CreatePopupMenu();
//lpCoolMenuItemInfo.hSubMenu = NULL;
//lpCoolMenuItemInfo.HotImageListIndex = ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_TEST));
//lpCoolMenuItemInfo.NormalImageIndex = ::LoadIcon(NULL, IDI_TEST);
strcpy(lpCoolMenuItemInfo.szText, "Test 1"); //"Context Menu";
lpCoolMenuItemInfo.uPos = 0;
lpCoolMenuItemInfo.wID = 1;
MENUITEMINFO MenuItemInfo;
MenuItemInfo.fMask = MIIM_TYPE | MIIM_STATE;
MenuItemInfo.fState = MFS_DEFAULT ;
if (lpCoolMenuItemInfo.fType == MFT_SEPARATOR)
{
MenuItemInfo.fType = lpCoolMenuItemInfo.fType;
return InsertMenuItem(hPopMenu,lpCoolMenuItemInfo.uPos,1,&MenuItemInfo);
}
else
{
MenuItemInfo.fMask |= MIIM_DATA | MIIM_ID;
MenuItemInfo.fType = MFT_OWNERDRAW;
MenuItemInfo.wID = lpCoolMenuItemInfo.wID;
MenuItemInfo.cbSize = sizeof(MenuItemInfo);
MMMENUITEMINFOPTR lpcmii = (MMMENUITEMINFOPTR) ::malloc(sizeof(lpCoolMenuItemInfo));
MenuItemInfo.dwItemData = (unsigned long) lpcmii;
::strcpy (lpcmii->szText, "Microsite" ); //lpCoolMenuItemInfo.szText) ;
//lpcmii->HotImageListIndex = lpCoolMenuItemInfo.HotImageListIndex;
//lpcmii->NormalImageIndex = lpCoolMenuItemInfo.NormalImageIndex;
lpcmii->uPos = lpCoolMenuItemInfo.uPos;
lpcmii->fType = MenuItemInfo.fType;
//lpcmii->cAccel = *(p+1);
::InsertMenuItem(hPopMenu,lpCoolMenuItemInfo.uPos,1,&MenuItemInfo);
}
strcpy(lpCoolMenuItemInfo1.szText, "Test Part 2"); //"Context Menu";
lpCoolMenuItemInfo1.uPos = 1;
lpCoolMenuItemInfo1.wID = 2;
MENUITEMINFO MenuItemInfo1;
MenuItemInfo1.fMask = MIIM_TYPE | MIIM_STATE;
MenuItemInfo1.fState = MFS_DEFAULT;
if (lpCoolMenuItemInfo1.fType == MFT_SEPARATOR)
{
MenuItemInfo1.fType = lpCoolMenuItemInfo1.fType;
return InsertMenuItem(hPopMenu,lpCoolMenuItemInfo1.uPos,1,&MenuItemInfo1);
}
else
{
MenuItemInfo1.fMask = MIIM_TYPE | MIIM_DATA;
MenuItemInfo1.fType = MFT_OWNERDRAW;
MenuItemInfo1.wID = lpCoolMenuItemInfo1.wID;
MenuItemInfo1.cbSize = sizeof(MenuItemInfo1);
MMMENUITEMINFOPTR lpcmii1 = (MMMENUITEMINFOPTR) ::malloc(sizeof(lpCoolMenuItemInfo1));
//MenuItemInfo1.dwItemData = (unsigned long) lpcmii1;
MenuItemInfo1.dwTypeData = lpcmii1->szText;
MenuItemInfo1.cch = 256;
::strcpy (lpcmii1->szText, "Test 2" ); //lpCoolMenuItemInfo.szText) ;
//lpcmii->HotImageListIndex = lpCoolMenuItemInfo.HotImageListIndex;
//lpcmii->NormalImageIndex = lpCoolMenuItemInfo.NormalImageIndex;
lpcmii1->uPos = lpCoolMenuItemInfo1.uPos;
lpcmii1->fType = MenuItemInfo1.fType;
//lpcmii->cAccel = *(p+1);
::InsertMenuItem(hPopMenu,lpCoolMenuItemInfo1.uPos,1,&MenuItemInfo1);
}
I have tried doing this using OWNERDRAW and somehow the menu appears but without any text.
Thanks
|
|
|
|
|
I'm coding a winsock program, and I want to be able to take some of the data recieved, and print it to the screen. Since I recieved the data in a global function, I used code that looks like
((CMainDlg*)::AfxGetMainWnd())->SendData(sBuffer);
When I try to change the window text on a static control I get errors, as well as if I try to access any of the member variables. Any ideas?
-KMaz
|
|
|
|
|
There are several solutions. What I/O model does the program utilize? One importance of I/O model is knowing when and how the program receives the data. Afterward, you can design a way to transfer the incoming data to MFC's thread. One solution could be messages. Another solution could be a static data member and a critical section.
Kuphryn
|
|
|
|
|
kuphryn wrote:
What I/O model does the program utilize?
I am unfamiliar with the term I/O model....could you clear up what that means?
KMaz
|
|
|
|
|
I/O model symbolize how the program manage winsock I/O. Under a non-blocking I/O model, calls to WSARecv() and WSASend(), for example, returns immediately. There is not waiting.
Kuphryn
|
|
|
|
|
Another possibility is that your program is using different threads to do your thread I/O. If this is the case, it is not straightforward to update MFC UI objects in another thread.
Another possibility is that your receive function does not NULL terminate the received buffer.
|
|
|
|
|
I am developing an application in VC++ 6.0 with MFC(4.2, I think). Originally I was developing on Win98, but have since changed to WinXP. I notice that my dialogs, property sheets, etc. still have a Win98 look, even after I rebuilt on XP. I would like them to have the WinXP look, but I don't know how. Do I need to a newer version of Visual Studio, a new version of MFC perhaps?
Any help is much appreciated.
Thanks
Dermot
|
|
|
|
|
You need to either add a manifest file or add a manifest entry to your .RC file. I'm sure if you spend a few minutes searching the CP articles, you'll find the info you need.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Is there a way to receive a double click notice on a Static or Edit Control.
|
|
|
|
|
Yes, have you looked at NM_DBLCLK?
|
|
|
|
|
Hi, I am trying to get a handle to part of a loaded bitmap using CreateCompatibleBitmap but after I select this bitmap into a DC and BitBlt it always comes out as a black square. Maybe I don't understand exactly how the function is supposed to work. Here is my code:
HBITMAP LoadPartialBitmap(HWND hwnd)
{
HDC hdc, hdcMem;
HBITMAP hBitmapMain;
HBITMAP hBitmap;
hBitmapMain = (HBITMAP) LoadImage(NULL, "button.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hdc = GetDC(hwnd);
hdcMem = CreateCompatibleDC(hdc);
SelectObject(hdcMem, hBitmapMain);
BitBlt(hdc, 0, 0, 30, 30, hdcMem, 20, 20, SRCCOPY);
hBitmap = CreateCompatibleBitmap(hdc, 30, 30);
ReleaseDC(hwnd, hdc);
DeleteDC(hdcMem);
return hBitmap;
}
Am I using this function completely wrong?
|
|
|
|
|
the problem is that hBitmap is empty when you return it. you haven't drawn into it, or BitBlt'd into it, so it's just a blank bitmap.
it looks like your code is correct for the display of the bitmap, now you need to essentially duplicate that but this time you're "displaying" into your temp DC, and onto hBitmap. in other words:
after you display to hdc (with the BitBlt), do another SelectObject to select hBitmap into hdcMem.
then, BitBlt from hdc to hdcMem. after this, hBitmap will have the result of the Blt.
then, de-select hBitmap from the DC (by using the return value from the first SelectObject call in a final (3rd) SelectObject(hdmMem)).
-c
|
|
|
|
|
Great, works like a charm, I understand the logic now...Thanks for the help.
|
|
|
|
|
hello people.i would like to know if it's possible in vc++ 6 to have a feature that .net has.i mean the one that u can hide a functions or all the functions and a + appears.i hope u understand my question.like tree controls...
thx!
|
|
|
|
|
I am looking at the windows forms. Everything looks so easy now..like making and attaching menus etc. But theres nodrg and drop of controls from a toolbox and figuring out where to position controls is such a hassle. SO does any one actually use this for GUI design? Also if theres no doc-view architecture, then it looks like your app is just a bunch of CDialog type windows......
What are the reasons why one would want to use windows forms and not MFC?
Appreciate your help,
ns
|
|
|
|
|
First easy answer, why not, it's a new technology, and getting the hang of it as early as possible is a good thing.
the visual aspect of building UI in VC6 is not yet operation in the .net version of Managed C++; will be in Everett (the next version of VC++.net, me think).
But you should try to learn as much as possible how to do things by hand even if there's a UI builder, it will force you to learn more of the underlying concepts and potential problem.
Windows Forms is not a dialog based toolkit, the frame work offer much more than dialogs; the Doc-View architecture is not bad if you keep inside the limitation of the model, we removed the concept of the doc-view by handling everything ourselves, and at the end, made life so much easier.
I like the .net framework, I wish I could spend more time on it.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Thanks! Yes _ I am enjoying the ms press book "step by step..." except I cant get its sample code to compile for some reason. Anyways its very clean and wrapped up and not difficult to switch to conceptually.........
Appreciate your help,
ns
|
|
|
|
|
I think the latest version of VS .Net (due 4/23) has a resource editor. It should be part of your MSDN release.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
i don´t know how can i convert from 'class _variant_t' to 'int' ????
thanx for your time
el hombre arriesga su vida cada vez que elige y eso es lo que lo hace libre
|
|
|
|
|
If i could have a better example of what you are trying to do, i might be able to help?
|
|
|
|
|
it may be help you.
_variant_t vt;
int nValue;
nValue=vt.intVal;
anju
|
|
|
|
|
Hello,
I am trying to write this array of the following type to file:
typedef struct tagDIBFILEHDR
{
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} DIBFILEHDR;
Thats the same struct as BITMAPFILEHEADER.
The correct output should be (hex):
42 4D 36 68 00 00 00 00 00 00 36 04 00 00
But after compiling the program with MSVC++ it outputs the following:
42 4D 00 00 36 68 00 00 00 00 00 00 36 04 00 00
So why does MSVC++ swap/insert zero bytes there???
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Byte packing. Check out the /Zp compiler switch.
|
|
|
|