|
What I want to achieve is that my tabbed windows use the IsDialogMessage to behave as if they were dialogs.
So I have implemented a handler for WM_FORWARDMSG in each of my tabviews windows.
In my MainFrame I call tabview.PreTranslateMessage() which correctly forwards the message to the current active tab window.
My CWindowImpl of each tab window has this:
MESSAGE_HANDLER_EX(WM_FORWARDMSG, OnForwardMsg)
LRESULT OnForwardMsg(UINT uMsg, WPARAM wParam, LPARAM lParam)
return IsDialogMessage((LPMSG)lParam);
}
However, pressing the VK_RETURN or VK_ESCAPE key does not result in a WM_COMMAND message being sent to the tabviews window.
Happy coding,
Philipp Kursawe
|
|
|
|
|
Sorry, I don't understand the relationship with your OP
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
I have a base template class
template<class T, UINT titleId, int SortIndex, class WindowClass = ATL::CWindowImpl<T>>
class ATL_NO_VTABLE ITabPageImpl : public WindowClass {
BEGIN_MSG_MAP_EX(ITabPageImpl)
MSG_WM_CREATE(onCreate)
MSG_WM_DESTROY(onDestroy)
REFLECT_NOTIFICATIONS_EX()
ALT_MSG_MAP(1)
NOTIFY_CODE_HANDLER_EX(LVN_DELETEITEM, onModifyTable)
END_MSG_MAP()
ITabPageImpl() : _table(this, 1) {}
private:
ATL::CContainedWindowT<WTL::CListViewCtrl> _table;
In the onCreate method I subclass a control, if the implementation provides a specific method:
__if_exists(T::getTableControl) {
_table.SubclassWindow(static_cast<T*>(this)->getTableControl());
}
However, after subclassing the message loop of T produces an assertion when the subclassed control is supposed to process its first message.
The basic Idea is, that I want to put handling of certain messages in the base class and lift the burden on implementation classes.
Thanks for any help!
Happy coding,
Philipp Kursawe
|
|
|
|
|
Hi Philipp,
You are misunderstanding ATL::CContainedWindow operation. Post on the WTL support list[^] for help.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Thanks Alain for your reply!
Maybe I should describe what I want to achieve: I want to subclass a child window and pre-handle certain messages in my class before the child window can process them itself.
I thought CContainedWindow was the way to go then?
In the particular case I want to set the background colour of the window.
Happy coding,
Philipp Kursawe
|
|
|
|
|
Hello,
I am struggling to fit CListBoxCtrl and CDoubleBufferWindowImpl together.
I have a owner drawn listbox ready, whose MSG_WM_DRAWITEM I handle in the parent control for now.
I guess the first step would be to move the MSG_WM_DRAWITEM message handling to my custom listbox control.
How would I then also fit in the double buffer technique?
My solution was something like in the DoPaint method to call the original controls DefWndProc but that does not work.
Any ideas?
Happy coding,
Philipp Kursawe
|
|
|
|
|
Hi Philipp,
Philipp Kursawe wrote: I guess the first step would be to move the MSG_WM_DRAWITEM message handling to
my custom listbox control
It may be your choice but it's not the first step.
You need to use a double buffered CListBox , for instance:
class CMyListBox : public CDoubleBufferWindowImpl<CMyListBox, CListBox, ATL::CControlWinTraits>
{
BEGIN_MSG_MAP(CMyListBox)
CHAIN_MSG_MAP(CDoubleBufferWindowImpl)
END_MSG_MAP()
void DoPaint(HDC hdc)
{
DefWindowProc(WM_PAINT, (WPARAM)hdc, 0);
}
};
If you subclass the listbox in your parent dialog OnInit() , you can check with breakpoints that the dc referenced in your DrawItem() member is the MemoryDC set in CMyListBox::DoPaint() .
My test code:
class CTest0View :
public CDialogImpl<CTest0View>,
public COwnerDraw<CTest0View>
{
public:
enum { IDD = IDD_TEST0_FORM };
CMyListBox m_lb;
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
return;
}
BEGIN_MSG_MAP(CTest0View)
MESSAGE_HANDLER(WM_INITDIALOG, OnInit)
CHAIN_MSG_MAP(COwnerDraw<CTest0View>)
FORWARD_NOTIFICATIONS()
END_MSG_MAP()
LRESULT OnInit(UINT , WPARAM , LPARAM , BOOL& bHandled)
{
m_lb.SubclassWindow(GetDlgItem(IDC_LIST1));
m_lb.AddString(L"Titi");
m_lb.AddString(L"Tata");
m_lb.AddString(L"Toto");
return bHandled = FALSE;
}
};
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Thanks Alain, this works (almost)!
I am using your WTL::CControlDialogImpl to show the listbox in a modal dialog. The drawing is a little off now.
void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT item)
if (item->itemID == -1) return;
WTL::CDCHandle dc(item->hDC);
dc.GradientFillRect(item->rcItem, RGB(200,200,200), RGB(10,10,10), false);
if (item->itemState == ODS_FOCUS) {
dc.SetTextColor(RGB(255,255,255));
} else {
dc.SetTextColor(RGB(255,255,255));
}
WCHAR text[1024];
int chars = m_Ctrl.GetText(item->itemID, text);
dc.SetBkMode(TRANSPARENT);
dc.SelectFont(font);
dc.DrawText(text, chars, &item->rcItem, DT_NOPREFIX | DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_END_ELLIPSIS);
}
After some rows the gradients stop to show up and the background is just the standard window color.
Happy coding,
Philipp Kursawe
|
|
|
|
|
Hi, everyone!
I had encounter a problem while I am developing a add-in for Word. I make a class derived from IViewObject and implement my own OnDraw. In OnDraw, I create a compatible DC from the parameter with OnDraw whose type is ATL_DRAWINFO. But the compatible DC can't be created correctly in most time. The error code I get is 183 (The file is existed and it can't be created). I don't know the reason. I guess maybe Microsoft don't allow others to do that, isn't it?
After then, I try to get a DC by GetDC or GetWindowDC. But the object I draw through them isn't in the client area of Word. Maybe I need to get the DC of Client-area of Word. But I don't know how to get it. Even I doubt whether the DC of Client-area is exist. I hope someone could be kind to tell me how to resolve this problem. Thx!
Whiteclouds.
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
Hi all
I have a problema with MDITabbedControl.
- Open multiple MDI tab screens
- Select a tab from one of them and start moving it. Drop it on the "X" thing that closes the screen from another tab
- Now move your mouse over the other tabs. As the mouse passes over the tab, the tab still captured, mouse doesn't release the capture.
I try overloading pretranslatemsg, catching the message WM_LBUTTONUP, but still happens when during a drag/drop I click on close button.
This is my code:
switch (pMsg->message)
{
case WM_LBUTTONUP:
{
CWnd* pWnd = FromHandle(pMsg->hwnd);
CMFCTabCtrl* tabGroup = dynamic_cast<CMFCTabCtrl*>(pWnd);
if (tabGroup)
{
CPoint clickLocation = pMsg->pt;
tabGroup->ScreenToClient(&clickLocation);
int tabIndex = tabGroup->GetTabFromPoint(clickLocation);
if (tabIndex >= 0)
{
CWnd* pTab = tabGroup->GetTabWnd(tabIndex);
if (pTab && tabGroup->IsTabCloseButtonHighlighted() && tabGroup->IsTabCloseButtonPressed())
{
pTab->SendMessage(WM_CLOSE, 0, 0);
}
}
}
break;
}
default:
{
break;
}
}
return CMDIFrameWndEx::PreTranslateMessage(pMsg);
|
|
|
|
|
In Multiline Edit control, a new line to be formed form after ALT+ENTER instead of Enter, this has similar behaviour has IM messengers etc., how can I enable the same, I learned the Keyboard virtual keys, VK_MENU for ALT ; VK_RETURN for Enter,(PreTransalateMessage ()) Pls., let me know the combinations to form a new line.
PreTranslatemessage()
<...
// ENTER key
if( (( pMsg->message == WM_KEYDOWN ) && ( pMsg->wParam == VK_MENU ) )
||( ( pMsg->message == WM_KEYDOWN ) && ( pMsg->wParam == VK_RETURN )) )
{
//Enter key was hit -> do whatever you want
// ProcessEnterkey();
/*m_wndCMDWnd.GetLine((nIndex,lpszBuffer);*/
return TRUE;
}
above code is valid for <<enter>>, but the same should be working for <<alt+enter>> ie., form a new line , Pls., let me know how to accomplish the same.
|
|
|
|
|
Alt key combination is treated as system key which cannot be handled by WM_KEYDOWN. Use WM_SYSKEYDOWN Message instead.
if (pMsg->message == WM_SYSKEYDOWN)
{
if( pMsg->wParam == VK_RETURN)
{
}
}
|
|
|
|
|
Please help write to give me.
thanks in advance.
|
|
|
|
|
Is this a homework?
What is difficult in this or what is the thing that is stopping you from going ahead and finishing off the assignment.
Start coding, and post your code in case you face any issues and then someone here might help you.
Also, as per the forum guidelines this is not the correct forum for posting this question.
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
|
In that case get on with it yourself rather than expecting someone else to do it for you.
I must get a clever new signature for 2011.
|
|
|
|
|
|
Hello. I have the following code block:
#include <stdlib.h>
typedef struct List_s
{
int count;
void **items;
} List;
List *list_create()
{
List *list = malloc (sizeof (List));
list->count = 0;
list->items = malloc (1 * sizeof (void *));
return list;
}
void list_add (List *list, void *item)
{
list->items = realloc (list->items, (list->count + 1) * sizeof (void *));
list->items[list->count] = item;
list->count++;
}
void list_dealloc (List *list)
{
for (int i = 0; i < list->count; i++)
{
free (list->items[i]);
}
free (list->items);
free (list);
}
When I pass a List to list_dealloc I get a segmentation fault on the line in the for loop. I can print the contents of items[i] just fine (in my test case it's the string "Hello"). I'm using gcc-4.5.1 on 64 bit Fedora 14 if that's anything useful.
modified on Monday, February 28, 2011 12:57 PM
|
|
|
|
|
Jordanwb wrote: segmentation fault on the line in the for loop
If the crash is at free() function, ensure that you are passing a heap pointer as item to list_add() function, not the address of a stack variable.
|
|
|
|
|
Are you sure that all the items passed in to your list through the list_add() function have been created by malloc() ?
I must get a clever new signature for 2011.
|
|
|
|
|
Thanks for replying. This is what's in my main() function:
List *list = list_create();
list_add (list, "Hello");
list_dealloc (list);
|
|
|
|
|
So you are adding a pointer to a constant string which you later try to free() : result SEGV fault. You need to ensure that every pointer you pass into list_add() is pointing to a memory block that has been returned from malloc() . something like:
List *list = list_create();
char* pitem = (char*)malloc(10);
strcpy(pitem, "Hello");
list_add (list, pitem);
list_dealloc (list);
I must get a clever new signature for 2011.
|
|
|
|
|
|
Hi,
I need to send a mail to a particular email address from the application. For this purpose, I am using MAPI APIs.
Following is the code which is used in the application. This code is working properly with MS Outlook Express; however, in Lotus Notes, email ID specified in the code is not added to the "To" field of email. Other values given in the MapiRecipDesc structure is added to the email properly.
Can any one help to solve the issue?
#include "stdafx.h"
#include "Mail Application.h"
#include <MAPI.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
MapiRecipDesc sender;
MapiRecipDesc recipient;
MapiMessage note;
HMODULE hinstMapi32Dll = NULL;
if (hinstMapi32Dll == NULL)
hinstMapi32Dll = ::LoadLibraryA("MAPI32.DLL");
if (hinstMapi32Dll == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_MAPI_LOAD);
return -1;
}
ULONG (PASCAL *lpfnMAPISendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG);
lpfnMAPISendMail = (LPMAPISENDMAIL)GetProcAddress( hinstMapi32Dll, "MAPISendMail");
sender.ulReserved = 0;
sender.ulRecipClass = MAPI_ORIG;
sender.lpszName = "My Name";
sender.lpszAddress = "me@myeamil.com";
sender.ulEIDSize = 0;
sender.lpEntryID = NULL;
recipient.ulReserved = 0;
recipient.ulRecipClass = MAPI_TO;
recipient.lpszName = "Person Name";
recipient.lpszAddress = "SMTP:towhomitmayconcern@email.com";
recipient.ulEIDSize = 0;
recipient.lpEntryID = NULL;
note.ulReserved = 0;
note.lpszSubject = "Subject goes here";
note.lpszNoteText = "Message body goes here";
note.lpszMessageType = NULL;
note.lpszDateReceived = NULL;
note.lpszConversationID = NULL;
note.flFlags = 0L;
note.lpOriginator = &sender;
note.nRecipCount = 1;
note.lpRecips = &recipient;
note.nFileCount = 0;
note.lpFiles = NULL;
nRetCode = lpfnMAPISendMail( 0, 0L, ¬e, MAPI_DIALOG, 0L );
}
return nRetCode;
}
Regards,
Vinoth
modified on Wednesday, February 23, 2011 12:01 AM
|
|
|
|
|
Can any one help on this?
Regards,
Vinoth
|
|
|
|
|