|
E.g. I have a toolbar to which I can add buttons. Each button has a menu with two menu items: "Configure" and "Remove". The menu is displayed when the right mouse button is clicked on the button.
The menu is a child of the toolbar, thus having the message routing taken care of in the toolbar.
The question is, how can I tell which button the menu was invoked on, in order to know which button to remove when the user selects "Remove"? Is my design all wrong or what?
I am going (more) insane over this...
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
I'm not 100% sure about this, but maybe GetFocus on the command handler will do...
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
FOrget about my first reply (it won't work). Best way is to store on some well known variable a pointer to the button that last issued the popmenu.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You can the id of the item selected by capturing the WM_MENUSELECT message.
|
|
|
|
|
The menu is already working fine. What I need to know is which button that invoked the menu. The button has a OnRButtonDown handler which displays the menu. When the user selects an item in the menu the command handling is taken care of in the parent toolbar. How do I make the toolbar aware of which button it was that issued the menu?
E.g.
CDynamicButton.cpp
void CDynamicButton::OnRButtonDown(UINT nFlags, CPoint point)
{
if (m_hMenu)
{
HMENU hSubMenu = NULL;
CRect rWnd;
hSubMenu = ::GetSubMenu(m_hMenu, 0);
GetWindowRect(rWnd);
::TrackPopupMenuEx(hSubMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON, rWnd.left, rWnd.bottom, m_hParentWndMenu, NULL);
}
CButton::OnRButtonDown(nFlags, point);
}
CMacroToolBarCtrl.cpp:
BEGIN_MESSAGE_MAP(CMacroToolBarCtrl, CDialogBar)
ON_UPDATE_COMMAND_UI(ID_MENU_REMOVE, OnMenuRemove)
END_MESSAGE_MAP()
void CMacroToolBarCtrl::OnMenuRemove(CCmdUI* pCmdUI)
{
}
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
(1) Use GetItemRect to get the RECTs of all the buttons in your toolbar.
(2) In your OnRButtonDown you can get the CPoint of the area where the mouse was clicked
(3) Now figure out from these two, where the mouse was clicked
Regards
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Well, that works for a CToolBar, but I am using a CDialogBar.
I think I have seen something somewhere about replacing original bitmap buttons in a CToolBar with all kinds of controls. Could this be an option?
(I want to use my own button class with only text on)
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Ok, I have solved it now.
Thanks for pointing me in the right direction!
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Hi ,
How do I edit/modify a control,
that is contained by some window
that runs in different process
I used the following code ( or something like this ):
CWin* win = desktop_window->FindWindow( NULL, "window caption" );
CEdit* edit = win->GetDlgItem( RESOURCE_ITEM_ID );
edit->SetWindowText("some text");
but the GetDlgItem returns NULL,
where is my mistake ?
thanks in advance,
Daniel Mark.
|
|
|
|
|
This is the correct way:
<br> CEdit* edit = (CEdit*)win->GetDlgItem( RESOURCE_ID ); <br>
It's very strange that the compiler didn't said anything about this!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Hi
I thing you got me wrong.
My question is not about the syntax of
the code I attached to the message.
My question is about the way to get the CEdit control
I got the RESOUCE_ID using the Spy++ utility
|
|
|
|
|
Let's say that you have an edit on a dialog in another app with ID 1245.
First we have to find the window that the edit is on:
CWnd* hWnd = FindWindow(classname, NULL); // Or try find the window by using the title
then we have to get the edit control:
CEdit* edit = (CEdit*)hWnd->GetDLgItem(1245);
set the text "Hello" in the edit box:
edit->SetWindowText("Hello");
If it still retur NULL it perhaps can be a view the edit is putted on. I don't think this would work then.
Then you have to find the window (view) and the find the edit in that window (view).
Wasn't this right?
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I am trying to implement a hex editor. I need a strategy to keep track of the modifications a user might be making in an open file.I thought of allocating a buffer of the size of the file , but this only works for small files.For large files this is highly inefficient.
Any suggestions as to how this can be done efficiently?
vimal
|
|
|
|
|
can you not keep track of the new data, the old data and a file offset and length?
---
"every year we invent better idiot proof systems and every year they invent better idiots ... and the linux zealots still aren't being sterilized"
|
|
|
|
|
I Want Changing a Cursor Icon In Visual c++ ?
thanks for your help
|
|
|
|
|
SetCursor()
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
--------------------------------------------------------------------------------
Can anybody upload or send me (fayegolf@hotmail.com) full working example,
which will create shortcut of DUN entry(.lnk) to it on the desktop.
Thank you!
|
|
|
|
|
|
Does anybody know how to eather insert a button into a RichEditCtrl or get the curser position on the RichEditCtrl?
cheers
Dor
|
|
|
|
|
Hi all,
I added a custom button to Outlook Express toolbar using Windows Hook.
However, my new button keeps showing up 'grayed' eventhough I set it's
state to 'TBSTATE_ENABLED'
before I inseted it to the toolbar. If you know how to set this button to
"enabled" state, please
enlight me with your knowledge. Following are the pieces of code that show
how I added a button to the toolbar.
Thanks.
LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
{
HWND hWnd;
TCHAR szClass[BUFSIZE];
if(nCode < 0)
return CallNextHookEx(g_hhHook, nCode, wParam, lParam);
hWnd = (HWND)wParam;
switch(nCode)
{
case HCBT_CREATEWND:
GetClassName(hWnd, szClass, sizeof(szClass) - 1);
if(!strcmp(szClass, "ATH_Note"))
{
g_bHookInit = FALSE;
g_pfnOutlookExProc =
(WNDPROC) SetWindowLong(hWnd, GWL_WNDPROC, (LONG)OutlookExpressProc);
}
break;
}
return CallNextHookEx(g_hhHook, nCode, wParam, lParam);
}
LRESULT CALLBACK OutlookExpressProc(HWND hwnd, UINT uiMsg, WPARAM wParam,
LPARAM lParam)
{
static int iTimerID = 0;
if (iTimerID == 0)
iTimerID = SetTimer(hwnd, 1, 100, NULL);
switch (uiMsg)
{
case WM_CREATE:
iTimerID = 0;
break;
case WM_TIMER:
KillTimer(hwnd, iTimerID);
if(!g_bHookInit)
{
HWND hwndSizableRebar;
HWND hwndReBarWindow32;
REBARBANDINFO rbBand;
hwndSizableRebar = FindWindowEx(hwnd, NULL, "SizableRebar", NULL);
hwndReBarWindow32 = FindWindowEx(hwndSizableRebar, NULL, "ReBarWindow32",
NULL);
rbBand.cbSize = sizeof(REBARBANDINFO);
rbBand.fMask = RBBIM_CHILD;
SendMessage(hwndReBarWindow32, RB_GETBANDINFO, 2, (LPARAM)&rbBand);
if(rbBand.hwndChild != NULL)
{
TBBUTTON tbButton;
SendMessage(rbBand.hwndChild, TB_GETBUTTON, 0, (LPARAM)&tbButton);
char szBuf[256];
LoadString(g_hInst, IDS_CUSTOMBTN, (LPSTR) &szBuf, strlen(szBuf) - 1);
int iBtnStringID = SendMessage(rbBand.hwndChild, TB_ADDSTRING, (WPARAM)
0, (LPARAM) (LPSTR) szBuf);
tbButton.idCommand = ID_OE_CUSTOMBTN;
tbButton.dwData = 100;
tbButton.iString = iBtnStringID;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_AUTOSIZE | TBSTYLE_BUTTON;
SendMessage(rbBand.hwndChild, TB_INSERTBUTTON, 1, (LPARAM)&tbButton);
g_hwndToolbar = rbBand.hwndChild;
g_bHookInit = TRUE;
}
}
break;
}
switch (LOWORD(wParam))
{
case ID_OE_CUSTOMBTN:
MessageBox(NULL, "CUSTOMBTN", "Outlook Express", IDOK);
break;
case ID_OE_SEND:
MessageBox(NULL, "Send", "Outlook Express", IDOK);
break;
default:
break;
}
return CallWindowProc(g_pfnOutlookExProc, hwnd, uiMsg, wParam, lParam);
}
|
|
|
|
|
Firstly, sorry for the subject
We have written a generic data-access layer which we use to execute stored procedures on a MS SQL Server database and return various data-types depending on the method called (recordset, array, integer etc.). This data-access layer is a COM+ object (because we need to call it from ASP) written with Visual Basic.
We are currently looking at doing a re-write to support some new functionality (XML, multiple output parameters and the like), what I would like to know is would there be a significant performance benefit in porting the code to Visual C++ as an ATL COM+ object?
I have made a number of ATL objects before and I am comfortable writing C++ but if the performance benefit isn't going to be measurable then I might as well leave the code in it's current Visual Basic form... Any input would be greatly appreciated.
William D. Bartholomew
|
|
|
|
|
Last time I checked, IDispatch calling (e.g. VB) was about 10.000 times slower (thats four orders of magnitude) than using the vftable. Depending on your app it will help, but in your case I think the SQL server is the bottleneck.
Of course that's no reason to not make it faster.
/Mike
|
|
|
|
|
Your opinion is appreciated. (Global storage, memory files???)
We want to build objects that are loose coupled and fairly easy to test independently. (Object = DLL, OCX, EXE, whatever). The typical amount of data passed between objects is 2 or 3k, but can be as high as 7 or 8 meg. Lastly, all objects are located on the same machine. Currently all objects are built in VC++ but other languages (VB maybe JAVA) will be used in the future.
In our prototype, object_A uses Cfile and Cachive to create a file on disk, then we use PostMessage to inform Object_B of the files name and location. This has worked great for keeping objects loosely coupled and performing independent testing and development.
Speed is not our overriding consideration, but in our release environment it would be desirable to avoid the writing to disk, furthermore the VB people tell me they cann’t read a Carchive format.
Assuming the VB people are correct then we can change our data format that is not a problem. (But not desirable either given the friendly nature of Carchinve.)
My question to you is about globally allocated memory and memory mapped files. First and foremost, if you are aware of a good book on the subject? Secondly, if you are aware of the pros and cons of either choice?
Thank you
LynnPhil@Qwest.net
|
|
|
|
|
My opinion would be to use the memory mapped file. It would required less change to your existing code, you could possibly just replace CFile with CMemFile.
|
|
|
|
|
Hi,
I haven been using GDI plus to convert a series of tifs to JPEG. Does anyone know how I can access the multiple pages that are suported by the TIF format.
Cheers
Richard
|
|
|
|
|