|
Hi All,
I have created a dialog based application in MFC with no title bar (its a skinned dialog). It does have a taskbar icon, but since I can't use the WS_SYSMENU attribiute, I cannot have a menu popup when the user right clicks the taskbar icon.
Is there a way I can either insert a sys menu without having a title bar, or better yet, work like WinAmp, which somehow traps the taskbar button mouse click and display any menu I want (kinda like a hack).
Thanks in advance,
Nick D.
by the time you read this you will have already read it
|
|
|
|
|
I'm not sure how to do it. If you notice Winamp starting a really CPU stressed machine, you'll see (before it manages to paint it's skin) that it indeed does have a title bar. There's messages which are sent related to the non client area of the window (WM_NCCALCSIZE etc) that you can probably use to make the title bar zero height. Then, you can handle WM_SYSMENU and modify the menu before it is displayed (to have the custom menu).
Chris Richardson
|
|
|
|
|
I did a skinned dialog by handling WM_ERASEBKGND and WM_NCPAINT so i could still have the title bar, I just painted over it... It just seemed the easiest way to have all the menus there and have it looking groovy.
cheers
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
Can you please let me know how you did this?
I want to be able to skin a dialog so that the skin covers the menu. I want to be able to click the menu through the skin. Is this what you did?
I have not been able to find a way to skin over the menu.
Thank you for your help.
An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky
www.mpic3.com - My PIC based MP3 player project
|
|
|
|
|
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
|
|
|
|