|
Hi,
I was trying to override menus and draw them in OnDrawItem. It worked fine till I tried to use it for pop-up menu items. For some reasons the same method doesn’t work well, and see the following effects:
1. An arrow is drawn on the right of every pop-up menu item even though I draw the menu item myself. How is it possible
2. Just as a child pop-up menu is displayed the parent pop-up window loses selection mark on the pop-up menu item (the parent item).
Does anybody know if there’s any specific to handling pop-up menu items as opposed to regular items
|
|
|
|
|
Have you searched the CodeProject menu article section for owner-drawn menus ?
Back to real work : D-27.
|
|
|
|
|
Hi .S.Rod,
Yes i have indeed, and may i then rephrase my question, in case you know something about windows menus:
Each pop-up menu item has an arrow on the right, even when we override the menu item to be ownerdrawn. Windows seems to pull drawing for the right pointing triangle outside drawing context for pop-up menu items. Then how to override this windows restriction and yet draw the triangle ourselves
I would appreciate your help on this one,
Thanx in advance,
Vitaly
|
|
|
|
|
I've got the data, and the format, but i can't find a function for drawing a bitmap on a static control...
Thanks all!
|
|
|
|
|
Why don't you use a PictureHolder control instead of a Static control ?
Back to real work : D-27.
|
|
|
|
|
What functions should i use on that then? It's NON-MFC my program.
|
|
|
|
|
A PictureHolder is one of the controls in the dialog editor. After you've dropped it on your dialog, you can set the properties adnset the bitmap attached to it.
Back to real work : D-27.
|
|
|
|
|
I remember reading about this you have to do is override one or two of the functions, it's easy to do all you have to do is declare them privatley in your class. Then it's fairly easy to obtain a dc, if you search the articles and find one about scaling images it's all covered in that and it was written by one of the founders of the website.
- Jason
|
|
|
|
|
I'm new to sockets and network programming and my qustion is
how should I change my client's code if the clien is behind a proxy
thanks in advance
|
|
|
|
|
Nothing particular, the target server your socket connects to is the proxy instead.
Back to real work : D-27.
|
|
|
|
|
Please, suggest me where I can find or purchase documentation or SDK for MS-Word 97 and 2000 DOC-file format. May be you can also suggest me where I can find or purchase any component, which can write data directly into DOC-file without using MS-Word OLE Automation Server functions, or which can directly convert MS-Word RTF-file into MS-Word DOC-file without using MS-Word OLE Automation Server functions.
|
|
|
|
|
Have fun[^]
(cross-posting is a bad habit.)
Back to real work : D-27.
|
|
|
|
|
Just a begginer question ...
If I want to use COM components in my application, do I have to do something in my application ? Do I have to activate something ?
As I understand it I simply would have to do something like ( very simplified ) : as explained in Michael Dunn article :
ISomeCOMComponent* pInterface;
...
CoInitialize ( NULL );
...
CoCreateInstance(..., (void**) &pInterface );
...
...
pInterface->Release();
...
CoUninitialize();
Thanks.
|
|
|
|
|
This code is fine. Of course, in order to work, the COM object must be properly registered, otherwise CoCreateInstance will miserably fail.
(as long as your app is single-threaded, it's ok. But you may encounter issues with CoInitialize(NULL) on a per thread basis if your app is multi-threaded).
Back to real work : D-27.
|
|
|
|
|
Maximilien wrote:
Do I have to activate something ?
Yes, but you already do that with CoInitialize() and CoUninitialize()
So your code should work just fine
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi.
C++ offers the new operator to allocate a section of memory via heap.
C offers the general malloc set of functions to allocate a section of memory via heap.
Windows offers a series of functions. I would like to know what is the best memory allocation tool to use under windows. Again, I am a C++ programmer.
I believe Windows has these memory related functions.
GlobalAlloc()
GlobaFree()
HeapAlloc()
HeapFree()
LocalAlloc()
LocalFree ()
I would like to like under a C++ Windows program, what are the most appropriate memory allocation tool to use? Currently, I use C++ new operator to develop Windows winsock programs. However, I see programmers use GlobalAlloc almost all the time for Windows and Windows network programs. What is the advantage, if any, of GlobalAlloc that C++ new lacks, if any?
Thanks,
Kuphryn
|
|
|
|
|
Well, for all intensive purposes, Global/Local/HeapAlloc/Free() amount to the same thing, since windows doesn't provide a separate local and global heap. As the SDK documentation states, you should probably avoid using the "Local/Global" functions to allocate heap memory, because they are slower and don't provide as many features, and use the Heap* functions instead, but you need to review the documentation to see what fits best for a particular need.
HeapAlloc*ated memory isn't movable. GlobalAlloc*ated memory is guaranteed to be aligned on an 8-byte boundary, and are still used a lot in DDE, clipboard and OLE data objects.
There is also Virtual* functions as well.
Here's something that may help in comparing them (from MSDN):
- The following functions are equivalent: GlobalAlloc, LocalAlloc, and HeapAlloc with the handle returned by the GetProcessHeap function.
- The VirtualAlloc function allows you to specify additional options for memory allocation. However, its allocations use a page granularity, so using VirtualAlloc can result in higher memory usage.
- The malloc function has the disadvantage of being run-time dependent. The new operator has the disadvantage of being compiler dependent and language dependent.
- The CoTaskMemAlloc function has the advantage of working well in either C, C++, or Visual Basic. It is also the only way to share memory in a COM-based application, since MIDL uses CoTaskMemAlloc and CoTaskMemFree to marshal memory.
Of course, in C++, you'd use new so you can call constructors, which is a good thing But for struct ures (that don't do C++ things, since structs are completely public classes in C++), the Win32 Memory Management functions are quite useful.
|
|
|
|
|
|
|
Hi all,
I have a function (see following function), takes a structure of file information and file name. It prints the file with appropriate exe file according to their extention.
file information structure contains: file name, file type, file date, file size...etc.
I dont' get any problem printing the first file but crash for second file to print..
Is it because of the way I defined ShellExecuteInfo???
If so, what is the problem and how to fix it???
Thank you.
<br />
int myfunction(FileInfo afile, CString fileName)<br />
{<br />
int wordfile=0;<br />
CString msg;<br />
CString filetype = afile->type;<br />
<br />
int found =0;<br />
<br />
SHELLEXECUTEINFO lpExecInfo;<br />
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); <br />
lpExecInfo.lpVerb = "open";
lpExecInfo.lpDirectory = NULL; <br />
lpExecInfo.nShow = SW_SHOW ;
lpExecInfo.hInstApp = (HINSTANCE) SE_ERR_DDEFAIL ;
<br />
if(filetype.CompareNoCase(".xls") == 0 || filetype.CompareNoCase(".csv") == 0 || filetype.CompareNoCase(".csv") == 0|| filetype.CompareNoCase(".wks") == 0 || filetype.CompareNoCase(".zip")==0)<br />
{ <br />
<br />
else if(filetype.CompareNoCase(".xls") == 0 || filetype.CompareNoCase(".csv") == 0|| filetype.CompareNoCase(".wks") == 0)<br />
{<br />
found = 1; <br />
AfxMessageBox(" EXCEL FILE FOUND !!!\n\tPrint it manually"); <br />
lpExecInfo.lpFile = "j:\\smp\\smp\\printExcel\\debug\\printexcel.exe";
lpExecInfo.lpParameters = fileName;
msg.Empty();<br />
msg = "Printing " + fileName + " completed.\n Press OK to continue...";<br />
<br />
<br />
}
<br />
else if(filetype.CompareNoCase(".doc")== 0 || filetype.CompareNoCase(".rtf")==0 || filetype.CompareNoCase(".htm") == 0 || filetype.CompareNoCase(".html")==0)<br />
{<br />
wordfile = 1;<br />
found = 1; <br />
lpExecInfo.lpFile = "j:\\smp\\smp\\wordprinting\\debug\\wordprinting.exe";
lpExecInfo.lpParameters = fileName;
<br />
}
<br />
else if(filetype.CompareNoCase(".msg")==0)<br />
{<br />
lpExecInfo.lpFile = fileName;
<br />
}
<br />
ShellExecuteEx(&lpExecInfo); <font color="red">here where I got error for second file.</font><br />
<br />
if(lpExecInfo.hProcess !=NULL)<br />
{<br />
::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);<br />
::CloseHandle(lpExecInfo.hProcess);<br />
} <br />
if(wordfile != 1)<br />
MessageBox(msg);<br />
<br />
}
return found;<br />
}<br />
|
|
|
|
|
You didn't say what the error is, but I see two problems. First, the fMask member of the struct is not initialized, so it has garbage in it. It's always a good idea to zero-init structs. Second, for the hProcess member to be filled in, fMask must include SEE_MASK_NOCLOSEPROCESS.
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
yes.. you were right.. i missed that..
the error was just crash.. you know general protection error.
Thanks.
|
|
|
|
|
Howdy,
I have a SDI (chat) app, in my CView I create 2 Rich Edit windows one fills 80%(top of CView receive text) and the other fills the last 20% (bottom Send text) they are both classes derived from CRichEditCtrl.
For some reason these 2 controls are not receiving my SendMessage commands from CView on 9x machines. (The sendmessage commands work fine on Windows 2k.) I have looked up the messages on MSDN and they should work on any 9x platform and nt 3.51 and up with RichEdit 1.0, the messages are:
EM_SCROLLCARET
EM_EXSETSEL
EM_GETEVENTMASK
Plus my Context Menus containded in my derived RichEdit classes do not display on 9x machines.
I know this is probably vague but does anyone have any suggestions?
|
|
|
|
|
Use MSDEV Spy++ to figure out if messages are really processed or not.
Back to real work : D-27.
|
|
|
|
|
Hi,
I do not know why I can not control "Size" of the chars print out for most of the Default Printers (works only on Window XP)!
In Window XP if I change the follwing command ... then it changes the size ( 9 & 72), but for others ... nothing affected! Can someone help me to pin-point the problem?
<br />
lf.lfHeight = -MulDiv(9, dc.GetDeviceCaps(LOGPIXELSY), 72);<br />
Here is my whole codes:
<br />
CPrintDialog printDlg(FALSE, PD_RETURNDEFAULT | PD_RETURNDC);CHeaderCtrl *pHeader = m_saleReport.GetHeaderCtrl();<br />
<br />
int i;<br />
<br />
if (printDlg.DoModal() == IDCANCEL)
return;<br />
<br />
CDC dc;<br />
CPrintInfo Info;<br />
CFont oFont;<br />
<br />
dc.Attach(printDlg.GetPrinterDC());
dc.SaveDC();
dc.m_bPrinting = TRUE;<br />
<br />
CString strTitle;
<br />
DOCINFO di;
::ZeroMemory (&di, sizeof (DOCINFO));<br />
<br />
di.cbSize = sizeof (DOCINFO);<br />
di.lpszDocName = strTitle;<br />
<br />
BOOL bPrintingOK = dc.StartDoc(&di);
<br />
int ppiX = dc.GetDeviceCaps(LOGPIXELSX);<br />
int ppiY = dc.GetDeviceCaps(LOGPIXELSY);<br />
<br />
int x0,y0,x1,y1;<br />
x0 = ppiX * (8 - 5.5)/2;
y0 = ppiY;
x1 = dc.GetDeviceCaps(HORZRES);
y1 = dc.GetDeviceCaps(VERTRES);
<br />
Info.m_rectDraw.SetRect(x0,y0,x1+400,y1);
<br />
<br />
LOGFONT lf; <br />
memset(&lf, 0, sizeof(LOGFONT));
::ZeroMemory(&lf, sizeof(LOGFONT));<br />
<br />
lf.lfHeight = -MulDiv(9, dc.GetDeviceCaps(LOGPIXELSY), 72);<br />
strcpy(lf.lfFaceName, "Garamond");
<br />
oFont.CreateFontIndirect(&lf);
dc.SelectObject(&oFont);
<br />
CString text("A") ;<br />
CSize csText = dc.GetTextExtent(text) ;
<br />
int lines_per_page = (int)(Info.m_rectDraw.Height() / csText.cy) ;<br />
int lines_in_listbox = m_saleSummary.GetCount();<br />
int headercolumn = pHeader->GetItemCount();<br />
int line_printing = 0 ;<br />
<br />
HDITEM hdi;<br />
TCHAR lpBuffer[256];<br />
bool fFound = false;<br />
<br />
hdi.mask = HDI_TEXT;<br />
hdi.pszText = lpBuffer;<br />
hdi.cchTextMax = 256;<br />
<br />
Info.SetMaxPage((lines_in_listbox / lines_per_page) + 1);<br />
<br />
for (UINT page = Info.GetMinPage();<br />
page <= Info.GetMaxPage() && bPrintingOK; page++)<br />
{<br />
Info.m_nCurPage = page;<br />
dc.StartPage();
CString Text; <br />
Text = m_saleReport.GetItemText(i,j);
dc.DrawText(Text, CRect(x, y, x + Info.m_rectDraw.Width(), y + csText.cy), DT_EXPANDTABS);<br />
}<br />
<br />
dc.EndPage();<br />
dc.EndDoc(); <br />
dc.RestoreDC(-1);
dc.DeleteDC() ;
Many thanks
|
|
|
|
|