|
I have recently been developing a class that needs to provide Listbox funtionality as a view. I initially created a CListbox derived class that supplies the needed owner draw implementation. Then I created a CView derived class, say CMyView, that, in turn, creates an instance of the ownerdraw listbox in its OnCreate(...) member. The CMyView::OnSize(...) member then sizes the ownerdraw listbox so that it occupies the entire CMyView client rect.
This implementation works fine, but it is my understanding that the CCtrlView class provides the functionality needed to use just about any control as a view. I have had some success in getting a CCtrlView derived view class that behaves as a listbox to work properly. However, I am unable to get the CCtrlView derived view class to receive the WM_DRAWITEM and WM_MEASUREITEM messages necessary for performing the owner draw tasks associated with the listbox.
If anyone knows how this task can be accomplished, please let me know.
|
|
|
|
|
How create transparency window, with posible size and move.
OlegO
|
|
|
|
|
Can somebody show me how to use the tool tip control in a dialog app? Could Microsoft have made this any harder?
|
|
|
|
|
Create a member function in your head file...
CToolTipCtrl m_ToolTips;
then.....
BOOL CJVFAccessDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
switch(pMsg->message)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
m_ToolTips.RelayEvent(pMsg);
}
return cdxCSizingDialog::PreTranslateMessage(pMsg);
}
BOOL CJVFAccessDlg::OnInitDialog()
{
m_ToolTips.Create(this);
m_ToolTips.SetDelayTime(200);
m_ToolTips.SetDelayTime(TTDT_AUTOPOP, 50000);
m_ToolTips.SetMaxTipWidth(200);
m_ToolTips.AddTool(GetDlgItem(IDD_REPORTS), winmesgs[7]);
m_ToolTips.AddTool(GetDlgItem(IDD_PERSONNEL), winmesgs[8]);
:
:
etc etc etc
return TRUE;
}
|
|
|
|
|
There are two MSDN documents that cover this:
"How to Add Tooltips for Controls to an MFC Modal Dialog Box"
(on the CD set)
- and -
"Tiptoe Through the ToolTips With Our All-Encompassing ToolTip Programmer's Guide"
(http://msdn.microsoft.com/library/periodic/period97/S245A9.htm)
Also, it is a good idea to put in an option to turn off tooltips in your dialog boxes. They can get annoying once you are familiar with using the application.
Good Luck
Jonathan Craig
|
|
|
|
|
Hi:
I am looking for the example source code for the Common Internet File System on the server and client site.
Can anybody tell me where to find it?
Thanks a lot....^_^
|
|
|
|
|
I recently have diffculty of using the Tab control!!! Anyone can help me out?? Thanks~!~
|
|
|
|
|
The number of pages to print from my document can vary from 4 to 10 pages. The printwork consist in a cover page as first page followed by 3 to 9 data pages. Each data page has a header and footer line. I correct the m_rectDraw in the pInfo structure for this header and footer line as indicated in the Scribble tutorial or by Prosise and Kruglinsky in their books. Printing is done in mapping mode MM_TEXT. With my "old" HP600 inktjet printer printing works fine and even the print preview works fine. But printing goes wrong on a HP Laserwriter, HP 1600CM inktjet printer and Lexmark OptraE laser printer on starting the 3rd page this is the 2nd data page,if the document has more than 7 data pages in a lane. How can I solve this problem ?
|
|
|
|
|
Here is some code I used for printing multi-page documents. It doesn't use the m_rectDraw for calculating the number of pages. It gets a printer device context from the current selected printer. Then calls GetDeviceCaps(HORZRES) and GetDeviceCaps(VERTRES) to get the printer page size.
BOOL CInfoWindowView::OnPreparePrinting(CPrintInfo* pInfo)
{
pInfo->SetMaxPage(GetNumberOfPrintPages(pInfo));
// default preparation
return DoPreparePrinting(pInfo);
}
WORD CInfoWindowView::GetNumberOfPrintPages(CPrintInfo* /*pInfo*/)
{
PRINTDLG PrtDlg;
HDC hDC;
//// Create a printer DC
if(!AfxGetApp()->GetPrinterDeviceDefaults(&PrtDlg))
{
TRACE("No default printer.\n");
// use screen DC for calculations
// It's OK to do this because this CDC will not be used for any
// output.
hDC = ::CreateDC("display",NULL,NULL,NULL);
}
else
{
CPrintDialog dlg(FALSE);
dlg.m_pd.hDevMode = PrtDlg.hDevMode;
dlg.m_pd.hDevNames = PrtDlg.hDevNames;
hDC = dlg.CreatePrinterDC();
}
CDC* pDC = CDC::FromHandle(hDC);
// This is a printer DC, so set m_bPrinting
// this is necessary so CScrollView::OnPrepareDC won't modify the
// ViewportOrg, and cause LPtoDP to return an inappropriate result.
pDC->m_bPrinting = TRUE;
//// Calculate print stuff.
CFont font;
CFont *pOldFont;
CSize size;
CInfoWindowDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//Setup the font.
font.CreatePointFont(INFO_WINDOW_FONT_SIZE, INFO_WINDOW_FONT_FACE, pDC);
pOldFont = pDC->SelectObject(&font);
size = pDC->GetTextExtent("X");
//// Get the printer page sizeS.
LONG lHeaderHeight;
LONG lFooterHeight;
LONG lPageWidth, lPageHeight;
lPageWidth = pDC->GetDeviceCaps(HORZRES);
lPageHeight = pDC->GetDeviceCaps(VERTRES);
//Header height is 4 lines.
lHeaderHeight = size.cy * 4;
//Footer height is 2 lines.
lFooterHeight = size.cy * 2;
//Set header, page, and footer rects.
m_rectPrintHeader.SetRect(0, 0, lPageWidth, lHeaderHeight);
//Print area for info.
m_rectPrintPage.SetRect(0, m_rectPrintHeader.bottom,
lPageWidth, m_rectPrintHeader.bottom +
(lPageHeight - (lHeaderHeight + lFooterHeight)));
//Footer area.
m_rectPrintFooter.SetRect(0, m_rectPrintPage.bottom,
lPageWidth, lPageHeight);
(size.cy * 1));
//Calculate other stuff.
m_wLinesPerPrinterPage = WORD(m_rectPrintPage.Height() / size.cy);
m_wPrinterPages = (WORD)ceil((double)pDoc->GetNumberOfTextLines() / m_wLinesPerPrinterPage);
m_wPrinterPages = (WORD)__max(m_wPrinterPages, 1);
//// Clean up.
pDC->SelectObject(pOldFont);
pDC->DeleteDC();
return m_wPrinterPages;
}
I hope this helps.
Jonathan Craig
|
|
|
|
|
Here you will find how I finally solved the problem. I thank Jonathan for his kind suggestion not to rely on the m_rectDraw in the CInfo structure. But even this does not solve the problem but it helps to have more consistent printwork between different printers.
I found a go around the problem by splitting the document in a view with, in my case, three sections as to keep the total number of pages under 8 pages for wich the standard MFC print functions work fine.
|
|
|
|
|
I have an application with more then 400 strings in the string table. Every time the string table grows over a certain number of strings, one of the strings of the string table appears in the alert message boxes instead of the system string to prompt when you have to save to file on closing a window or other error message box. Unwanted parts of a string from the string table apperas as caption in buttons on the print preview window. It seems that something goes wrong in the text segment and the string table overwrites some system strings. How can this be avoided or what I am doing wrong ?
|
|
|
|
|
So far I did'nt receive any reaction on my question. Are you all developing applications with low number of strings in the string table or are you not using the string table at all? I try to explain my problem on another way. What could be the reason when a string or parts from a string from the string table appears unwanted in a message box in stead of a system string, or on a static control or in a button caption as in the print preview ?
|
|
|
|
|
Hi all,
I would like to handle hardware events other than mouse or clipboard events by using a hook (WH_HARDWARE). Do anyone ever used the WH_HARDWARE.
If yes can I have an example.
Thanks.
Thanks, Alain-Serge.
|
|
|
|
|
|
Is there any way to create and show a dialog in a C console program?
Thanks in advance.
Erik Hammar
|
|
|
|
|
Hi Erik,
You should be able to show a dialog from a console application just the same way as in a GUI application.
Create a dialog resource and implement a dialog procedure, then call one of the CreateDialogXXX (for a modeless dialog) or DialogBoxXXX (for a modal dialog).
Cheers,
Paolo.
|
|
|
|
|
Can I make the modeless dialog stay on top, and have the console drawing something in the dialog, too?
Could you show me an example?
Thanks.
|
|
|
|
|
Hi Erik,
I think you can do that. To have the dialog always on top try:
SetWindowPos(hWndDialog, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
To draw on the client area of the dialog, first get a device context then just draw in it:
HDC hDC;
hDC = GetDC(hWndDialog);
TextOut(hDC, 10, 10, TEXT("Hello World!"), 12);
ReleaseDC(hWndDialog, hDC);
Hope this helps,
Paolo.
|
|
|
|
|
i have problem in list box for particular condition i should display the text in the different color anybody suggest what to do
|
|
|
|
|
You'll need to owner-draw the text. List boxes are ooooold and don't have many features.
Is it possible for you to switch to a list view control? It's trivial to change text color in such a control. I have written a tutorial on using custom draw that explains how to do it.
|
|
|
|
|
Try
http://codeguru.earthweb.com/listbox/colorlb.shtml
Mike's right List Boxes are pretty ooooollllldd
But in some scenarios they can be more useful than
List Controls
Regardz
Colin Davies
|
|
|
|
|
I sent you a class via email that does the following things:
1) Calculate horizontal scroll distance based on longest string in the listbox
2) Add or Insert strings with a specified color
3) Increase distance between listbox items
|
|
|
|
|
When ICQ approaches the screen edges, it docks there.
Other windows will have their maximum window size reduced (e.g. maximum width=screenwidth-icqwidth, maximum height=screenheight-icqheight)
How can I change the maximum size of all windows in the desktop? Are there any methods that I can change the windows in desktop environments?
Thanks all!
|
|
|
|
|
Unsure How ICQ works,
Generally this sort of feature is done by creating an "appbar"
Like the windows bar or office bar, and a few ticker tape controls,
Search out "AppBar"
Regardz
Colin Davies
|
|
|
|
|
I have an ATL control with a contained TreeView (using CContainedWindow).
The treeview flickers like you wouldn't believe when resized dynamically (the user can stretch its size in the container I am using). I have determined that the flicker is not due to the parent window of the tree.
Any ideas? I'm fresh out... To witness this phenomenon, use the ATL wizard to generate a control based on a treeview. Populate the tree with some items. Place the control on a VB form, and dynamically resize the control in the form's Resize event. Flicker city.
Nick Hodapp
|
|
|
|