|
Hi, I want to open the system menu of a window from code instead of as usual letting the user do it by right mouse-clicking on the top left icon. I use GetSystemMenu() to get the system menu and TrackPopupMenu() to display it. The system menu shows up but when I click on any menu item, nothing is routed back to the window. OnSysCommand() which normally receives system menu clicks is not called. However if the system menu is opened by the user as usual, everything works fine. What do I do wrong? How do I trap the menu item clicks?
Here’s the code from my test project, a standard dialog based application, TestDlg inherits from CDialog so this pointer is the dialog itself with the OnSysCommand() method.
void TestDlg::OnButton()
{
CMenu* pSysMenu = GetSystemMenu(FALSE);
pSysMenu->TrackPopupMenu(0, 100, 100, this);
}
/Thanks, Patric
/Patric
My C# blog: C# Coach
|
|
|
|
|
Try this instead:
void TestDlg::OnButton()
{
SendMessage( WM_SYSCHAR, VK_SPACE, 0x20000000 );
}
|
|
|
|
|
Thanks, it works.
/Patric
My C# blog: C# Coach
|
|
|
|
|
hey, im using visual studio 2003 and im coding this program in visual c++ .net. i compiled my program and made a release build, it runs on my pc, but it cant run on other peoples system, i cant figure out why, they are just getting the CLR error and i dont know how to fix it for them to run my program, any advice guys?
|
|
|
|
|
|
yes, they have 1.1 and 2.0 installed and still the CLR error comes up
|
|
|
|
|
okay, now its about the 'system.security.securityexecption' error, how do i allow other users to use my program as in give them permission?
|
|
|
|
|
Hi everybody. Long time no posting. Been busy working at the freeware Application and I'm almost done with the first beta : ). Also, I'm preparing an article for the Code Project. Anyway, I posted this message to see if any of you got any clue about the following problem:
Grabbing the DC of a window, copying it in a memory DC, drawing something (like a square for example) and then BitBlt-ing the result in the original window whenever you wish.
Take a look at this short code. It's supposed to grab a window DC and put it in a memory DC and return a handle to a DDB. It's from a book. My problem is that I want to do something similar, but I can't make it work. My experiments are kind of failed... so I won't post them. Here's the original code:
HBITMAP CaptureWindow(HWND hWnd)<br />
{<br />
RECT wnd;<br />
<br />
if ( ! GetWindowRect(hWnd, & wnd) )<br />
return NULL;<br />
<br />
HDC hDC = GetWindowDC(hWnd);<br />
<br />
HBITMAP hBmp = CreateCompatibleBitmap(hDC, wnd.right—wnd.left,<br />
wnd.bottom - wnd.top);<br />
<br />
if ( hBmp )<br />
{<br />
HDC hMemDC = CreateCompatibleDC(hDC);<br />
HGDIOBJ hOld = SelectObject(hMemDC, hBmp);<br />
<br />
BitBlt(hMemDC, 0, 0, wnd.right - wnd.left, wnd.bottom - wnd.top,<br />
hDC, 0, 0, SRCCOPY);<br />
<br />
SelectObject(hMemDC, hOld);<br />
DeleteObject(hMemDC);<br />
}<br />
ReleaseDC(hWnd, hDC);<br />
<br />
return hBmp;<br />
}
Now... could I somehow keep that Memory DC, draw something in it (say, a rectangle) and then bitblt it over the original window from which I created it? And perhaps after 2 seconds I want to do it again. Could I just bitblt it from my memory DC over the original window?
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Axonn Echysttas wrote:
Now... could I somehow keep that Memory DC, draw something in it (say, a rectangle) and then bitblt it over the original window from which I created it? And perhaps after 2 seconds I want to do it again. Could I just bitblt it from my memory DC over the original window?
I'm not sure, but I think that even if you manage to do that (I guess you'd need to use IntersectClipRect before any drawing in the original DC), what you draw there would be deleted next time the window draws itself... Or is that exactly what you need?
What exactly are you trying to do?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi,
may u plz look at this error:
#include <complex>
using namespace std;
complex <double> i(0,1); // to get i=sqrt(-1) !!
complex <double> c3 = 1/i ;
The last line gives the following error:
error C2782: 'class std::complex<_Ty> __cdecl std::operator /(const _Ty &,const class std::complex<_Ty> &)' : template parameter '_Ty' is ambiguous
could be 'double'
or 'int'
error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const _Ty &)' : could not deduce template argument for 'const class std::complex<_Ty> &' f
rom 'const int'
error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const class std::complex<_Ty> &)' : could not deduce template argument for 'const class st
d::complex<_Ty> &' from 'const int'
error C2677: binary '/' : no global operator defined which takes type 'class std::complex<double>' (or there is no acceptable conversion)
Error executing cl.exe.
It also doesn't accept:
complex <double> c3 = 1 + i ;
Any help is highly appreciated!
Regards,
Eliyah
|
|
|
|
|
|
no it doesn't work either!!
Thanks
|
|
|
|
|
It looks like complex is a template class, and you have not supplied a required argument. My guess is the argument is the type used for the real and imaginary values:
complex<double> complex_with_double_components;
complex<float> complex_with_float_components; I found this[^] on the MSDN; it should help.
Software Zen: delete this;
|
|
|
|
|
How much contention an InterlockedExchangeAdd can stand on a x86 box?
I'm looking for a rough figure how many threads would have to hit the same variable repeatedly how often before I get a notable slow down. I guess this is more critical on a multi-processor-system (so I can't test that)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
The interlocked shouldn't cause much trouble. They use a CPU opcode whichs locks the bus for the time that operation needs to complete. That's normally only a few CPU clocks.
I don't think that the performance of multi-processor-systems is influenced very much by this function because windows does use this kind of functions very frequently for every kind of synchronization!
Don't try it, just do it!
|
|
|
|
|
Hi
I want to find what is the memory usage my application
eg. myapp.exe is the output of myapp.cpp.
when the exe is running it has to print current memory usages at certain execution point.
//myapp.cpp
#iclude <iostream.h>
long getMemStatus()
{
//this method has to find what is the size of memory usage in its current process space
}
void main ()
{
cout<<"\n1. current mem usage:"<
|
|
|
|
|
You are not likely to see much difference for a 'new' on a single int variable unless your application is right on the threshold of an internal allocation block.
If you program is that sensitive to memory, you will probably have more memory trouble trying to find out how much remains than not doing so, since the act of looking up the memory and tracking it will consume memory itself!
Having said that, you can use the:
1. C runtime heap walking routines - these will tell yu what C runtime library allcoations posess
2. Win32 heap walking routines - what memory allcoations your process has made
3. Process memory usage for your entire process using VirtualQuery - find out where DLL are located and which ones are loaded, executable code image memory, reserved memory, commited memory, etc.
|
|
|
|
|
thanks
Blake Miller wrote:
You are not likely to see much difference for a 'new' on a single int variable unless your application is right on the threshold of an internal allocation block
My real problem is not for finding a single int size.
it is just a concept program.
Is there any already written code or example available?
|
|
|
|
|
I am not aware of any on CodeProject that use the VirtualQuery to traverse the memory layout.
|
|
|
|
|
hi,
i am using visual studio 2003, coding in c++. i would like to be able to select a function and find out which functions call the selected one, and then which functions call these, and so on.. is there any way to do this in VS, or does anyone know of an add-in that does this? thanks a lot =)
jay
|
|
|
|
|
see this[^] thread.
I am currently testing the DevPartner Profiler Community Edition
and am impressed by it so far.
I Dream of Absolute Zero
|
|
|
|
|
thanks a lot! that was one of the programs i was looking at, but i didn't realize there was a free version.
|
|
|
|
|
I wrote a simple DLL to smoothly stretch a supplied GDI HBITMAP using the GDI+ bilinear stretch algorithm. ( since GDI stretchblit with halftone is not good enough ) The Dll stretch function uses the drawimage command to write the stretched image directly to the device context of a window in another process. This works fine but it seems the drawimage command sends WM_NCPAINT and WM_ERASEBKGND messages to that window which causes flickering!!!
I could stretch to a memory device context and then bitblit the contents of the memory device context to the window, but the extra bitblt causes an unacceptable increase in CPU processing power.
Another solution would require injecting code into the other process to be able to subclass the window handler but this seems complex and may make the application susceptable to crashes.
Is there a simpler solution??? Any ideas or c++ source code of an image stretch routine with the same quality and speed of the gdiplus bilinear stretch?
VSKSTRETCH_API int WINAPI fnGdiPlusStretch(HBITMAP hBitmap,HDC hDest,int iXpos,int iYpos,int iWidth,int iHeight)
{
Bitmap* pBitMap = NULL;
CPalette Palette;
// +------------+
// | Gdi+ stuff |
// +------------+
HPALETTE hPalette = (HPALETTE)GetCurrentObject( hDest, OBJ_PAL) ;
//Palette.CreateHalftonePalette(hDest);
pBitMap = Bitmap::FromHBITMAP(hBitmap, (HPALETTE)Palette);
Graphics graphics(hDest); // Create Graphics object
graphics.SetInterpolationMode(InterpolationModeBilinear);
graphics.DrawImage(pBitMap,iXpos,iYpos,iWidth,iHeight);
delete pBitMap;
pBitMap = NULL;
return 0;
}
|
|
|
|
|
Okay, I have a question for you...
The MSDN states about the WNDCLASS.cbWndExtra the following:
"Specifies the number of extra bytes to allocate following the window instance. The system initializes the bytes to zero. If an application uses WNDCLASS to register a dialog box created by using the CLASS directive in the resource file, it must set this member to DLGWINDOWEXTRA."
So for example... If I want to store a pointer to some internal structure I need to store associated with a HWND, I can set this cbWndExtra member to sizeof(MyInternalStruct) with RegisterClass... But how can this extra memory be accessed as the HWND is declared as VOID* in windows.h?
|
|
|
|
|
See MSDN on GetClassLongPtr using GCL_CBCLSEXTRA then:
nIndex
[in] Specifies the value to retrieve. To retrieve a value from the extra class memory, specify the positive, zero-based byte offset of the value to be retrieved. Valid values are in the range zero through the number of bytes of extra class memory, minus eight; for example, if you specified 24 or more bytes of extra class memory, a value of 16 would be an index to the third integer.
|
|
|
|