|
Is it possible to get the height of the titlebar of a modeless CDialog? I have this code currently which fits the CDialog exactly into my ImageBox. I want it to fit such that the client area has the exact fit to the imagebox, and the titlebar extends above.
CRect picRect;
m_THBImage6.GetWindowRect(&picRect);
pdlg0->SetWindowPos(&CWnd::wndNoTopMost,picRect.left,picRect.top,picRect.Width(),picRect.Height(),SWP_SHOWWINDOW );
pdlg0->ShowWindow(SW_SHOW);
MSDN doesnt say, but does Width() return the number of pixels? In that case, I'd need to know the titlebar height in pixels too. I am thinking that the new code to do what I want would be:
CRect picRect;
m_THBImage6.GetWindowRect(&picRect);
pdlg0->SetWindowPos(&CWnd::wndNoTopMost,picRect.left,picRect.top,picRect.Width(),<code>picRect.Height()+ titleBarHeight</code>,SWP_SHOWWINDOW );
pdlg0->ShowWindow(SW_SHOW);
|
|
|
|
|
Use AdjustWindowRect[Ex].
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Simple and stupid question : I want to handle WM_HOTKEY in my CDialog dervied class, but I don't know how to do this ??
|
|
|
|
|
You'll have to add handler/message map entry (ON_MESSAGE) manually. Check ON_MESSAGE docs for more info.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Hi !
Anybody knows how can I highlite a specific line in the list control ?
If I try SetBkColor(..) it will do it fot the whole list.
I want to highlite just few items ?
Thank you !
|
|
|
|
|
SetItemState(itemIndex, LVIS_SELECTED, LVIS_SELECTED);
or
SetItemState(itemIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
|
You will most likely have to implement a custom draw algorithm for a specific line. Browse the list control section of CodeProject and CodeGuru for examples.
Kuphryn
|
|
|
|
|
To enable full row highlighting in a list control:
m_ctrlList.SetExtendedStyle(m_ctrlList.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
- Rob
|
|
|
|
|
I got the following suggestion (which worked, thanks) from one of you. Could anyone tell me where the wndTop argument came from and what it does? I did not declare it nor saw it anywhere in my code.
m_ProgBar.SetWindowPos(&wndTop,//???where did it come from?
rect.left,
rect.top,
rect.Width(),
rect.Height(),
NULL);
Thanks
ralf.riedel@usm.edu
|
|
|
|
|
CWnd::wndTop is MFC wrapper for HWND_TOP constant. Since you can't use constant where CWnd* is required, they had to create static object representing HWND_TOP value.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
|
I have created a custom, called CCustomListCtrl that inherits from CListCtrl. The only reason for this was to use the CustomDraw features.
I am using this CCustomCtrl in a dialog box and I have created it dynamically as following:
DWORD dwStyle;
dwStyle = LVS_REPORT | WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_BORDER | LVS_SINGLESEL ;
m_ControllerList.Create(dwStyle,
CRect(nLeft, nTop, nRight, nBottom), this, IDC_CONTROLLER_LIST);
m_ControllerList.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
Now, I don't have trouble catching any of the messages pertaining to the list within the CDialog class but it seems like messages pertaining to the header of the list (i.e. ColumnClick, etc) are all going to the CCustomCtrl file and I just don't seem to be able to trap them in my dialog class.
any ideas?
|
|
|
|
|
List control header's ID is zero. If you add handlers with ClassWizard, the message map entry will have control ID of your list, not zero. You'll have to change the ID value in message map or override OnNotify.
RK_2000 wrote:
I have created a custom, called CCustomListCtrl that inherits from CListCtrl. The only reason for this was to use the CustomDraw features.
You can use custom draw without creating new CListCtrl-based class. Message reflection makes it possible - handler will be created in dialog class and invoked whenever list needs painting.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
RK_2000 wrote:
it seems like messages pertaining to the header of the list (i.e. ColumnClick, etc) are all going to the CCustomCtrl file
That's how WM_NOTIFY works. A notification sent by a control (in this case, the header) goes to the control's parent (the list).
--Mike--
Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I am currently trying to work with COM and make a container to hold a Word document. What is happening is that I create the frame window, then insert the Word document, and it does what it should, it brings up the doc, puts the Word toolbars and menus on the window, etc. But one thing it does that is strange is that it has several of the toolbar buttons disabled. The Open, New, and Save buttons are disabled. Also, the Print button is enabled but when I click on it, it doesn't do anything. Other buttons, such as the spell check work fine. Everything seems to work fine when using the menus. Does anyone know why these buttons are disabled? How to enable these buttons? Anything about this issue?
I looked through several articles, such as the Using MS Office in an MFC Application but that doesn't ever mention anything like this....
|
|
|
|
|
Hi,
How can i place buttons in a list control? Do i need declare the CListCtrl's and buttons' styles as owner drawn?
Do i need to override OnDrawItem function of CListCtrl because it takes DRAWITEMSTRUCT parameter which has a CtlType member that can take an ODT_BUTTON value. If not, how should i do that?
Help me out on this one please.
Thanks in advance.
|
|
|
|
|
Going owner-draw and setting CtlType won't take you anywhere; CtlType is set by Windows.
Do you want to create a column of buttons in your list control?
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Yes, i want one column of the control to have buttons. Actually, my aim is to make the user insert rows and the button will be created at runtime. But i don't know how to create unique IDs at runtime and how to handle messages for the new buttons. This is a further step but if you have any suggestions on this problem too, i would love to hear it.
For placing button in list, i found a way like below:
Adding the following code in OnPaint or OnCreate function does it:
CRect itemRect;
GetSubItemRect( 0, 0, LVIR_LABEL, itemRect );
CTeamButton *buttonx = new CTeamButton;
buttonx->Create( "Test", WS_CHILD|WS_VISIBLE, itemRect, this, 12345 );
But it doesn't seem to be a solid and gentle way. For example, when you resize the columns the buttons' size doesn't change. It would get worse when sorting takes place. So i can't count on it. Is there any subtle way to achieve this?
Thanks.
|
|
|
|
|
MightyThor wrote:
Is there any subtle way to achieve this?
I'm afraid not. You may consider switching to grid control instead, especially if you plan to add editing capabilities.
http://www.codeproject.com/miscctrl/gridctrl.asp[^]
If you want to stay with CListCtrl, I think it's better to give up 'real' buttons and simulate them with custom-draw or owner-draw.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
I already checked grid control and it's a magnificent work, but the reason i'm trying to build my own component is mainly for self-education, so i better keep digging this custom-draw thing.
Thanks for your interest.
|
|
|
|
|
What's the minimal windowstyle to be used with CreateWindow()?
If I use WS_POPUP, the window doesn't show up.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
never mind, i forgot the width and height
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
Okay. I n many places I have stuff like:
m_FieldHolder = new CString [m_numFields ];
if the m_FieldHolder comes back as null, I will surely crash. This is in a function of a class, lets say. SO I of course can say:
if( m_FieldHolder)
{...
}
but what if its coming back as NULL? I will surely crash if I skip the code its supposed to do when not NULL. SO at this point, from the function in my class, how do I handle things? It would be nice to call a common global function each time new failed, but then do I exit? If I dont I cant predict what would happen since I have a zillion new , but in no case have I dealt with if its NULL then do what? I suppose I could pass info into my global NewFAilure() that would tell it which new it was that failed.
Ideas?
Thanks,
ns
|
|
|
|
|
ns wrote:
Ideas?
check everywhere. return error codes from all your functions, test the error codes and react accordingly. alternately, you can use C++ exception handing (thorw, try, catch). but, either way, you have to test and you have to handle error conditions.
IMO, programming is 25% implementing the task at hand and 75% watching for things that can go wrong. nothing infuriates a user more than unexpected failures. imagine if IE crased every time it found a JPG it didn't like (bad example, it already does that)
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|