|
I have written us a colour picker to replace the scabby Windows one, and especially with GDI+, allow us to enter alpha as well. My managet wants to be able to select colours from anywhere on the screen by clicking on them. Rather than make the dialog modeless, I decided to be cunning, and call SetCapture and then just check if I have clicked outside the dialog. I call SetCapture in OnInitDialog, and then in OnLButtonDOwn I do this:
CRect rc;
GetWindowRect(&rc);
CPoint pt = point;
ClientToScreen(&pt);
if (!rc.PtInRect(pt))
{
CWindowDC window(NULL);
COLORREF rgb = window.GetPixel(pt);
UpdateData();
m_Red = GetRValue(rgb);
m_Green = GetGValue(rgb);
m_Blue = GetBValue(rgb);
UpdateData(false);
ReleaseCapture();
SetCapture();
Invalidate(false);
return;
}
I've added releasecapture and setcapture to try and solve my problem, which is this. This all works great the first time I do it, after that it won't work at all. Clicking in the dialog works, of course, but I did a debug with a breakpoint set, and OnLButton down is not called again after time if I click outside the dialog. How can I keep the Capture for as long as the dialog is running ? Do I need to run a timer ? Why doesn't it work in the function as I wrote it ? Where's that piece of rope when I need it ?
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Where's that piece of rope when I need it ?
Here's the rope: "Mouse capture is also affected by the Windows 95 and Windows NT localized input queues.... If the mouse is captured while the mouse button is up, the window receives mouse input only as long as the mouse is over that window or another window created by the same thread."
".
From C++ QA by Paul Dilascia, MSJ, Dec'98.
Cheers,
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
How do we remove a popup menu I'm unable to get its Menu Id
thanks in Advance
vijay
|
|
|
|
|
Have you tried the BY_POSITION property?
|
|
|
|
|
Sorry, should be "MF_BYPOSITION"
|
|
|
|
|
|
what are the valid colours RGB Values for a 256 colour mode in VC++ How would you traverse from BLUE to RED traversing All the remaining colours thanks
Vijay
|
|
|
|
|
In 256 color mode, each color is represented by an 8 bit value. That value is an index into the color palette. Whatever the palette is set to for that index will be the "valid" color for that index. If you want to traverse from blue to red, you can create the color palette with 256 colors RGB( 255,0,0) to RGB(0,0,255 ), and than display them. Be careful though!
|
|
|
|
|
I am trying to write a program that will backup/restore registry settings to/from a file. I have found that RegSaveKey and RegRestoreKey need administrative privileges in order to work. This is of no use to me as it needs to be used by everyone.
Firstly, does anybody know how to get round such a problem I have tampered with the security descriptor and Enabled backup and restore privileges but despite my efforts I keep getting the WinError - "1314 A required privilege is not held by the client."
Secondly, does anybody know how to manually iterate though a desired regkey and all its subkeys (e.g. HKEY_CURRENT_USER/Software) and then load or save each subkey from/to a file to/from the registry. Such a scenerio I think will get round this privilege problem
Thanks in advance. Any contribution welcome.
|
|
|
|
|
|
Use regedit to do it. Something like:
char szTmpPath[MAX_PATH];
char szTmpFile[MAX_PATH];
HANDLE hRegEditHnd;
// get a name of a temp file.
status=GetTempPath( sizeof(szTmpPath), szTmpPath );
status=GetTempFileName( szTmpPath,"REG",0,szTmpFile );
// format args
strcpy (szArgs,"/e ");
strcat (szArgs,szTmpFile);
strcat (szArgs," \"HKEY_CURRENT_USER\\Software\"");
hRegEditHnd= (DWORD) ShellExecute( NULL, "open",
"regedit.exe", szArgs ,
NULL, SW_SHOWNORMAL );
That will save the specified key into a standard registry file in the (guaranteed unique) file specified by szTmpFile.
You should check the status's.
|
|
|
|
|
I'm using ado to join data in excel. but when i run my application i have a message box which appears where it's written the following message:"database erroritem cannot be found in the collection corresponding to the requested name or ordinal". I use the jet oledb 4.0 to find my filename:"provider=microsoft.jet.OLEDB.4.0;Data Source=%s;Extended Properties=Excel 8.0;","test.xls" and after to find the table name: table_name=pRstSchema->Fields->GetItem("TABLE_NAME")->Value;(where pRstSchema is a _RecordsetPtr smart pointer.
The TABLE_NAME is simply selected cells (A1:B10) I have called like that with the small edit box on the left top of the excel worksheet!
If someone could tell me why it doesn't work...
Gerald
|
|
|
|
|
Now, my YUV data is displayed in directdraw secondary surface by "UYVY" format.
But I want to know how to overlay YUY2 or YUV9 format data.
Please, teaching me how to set DDPIXELFORMAT and to write the YUV data in directdraw surface.
|
|
|
|
|
i'd like to design the same user interface as MS media player7. if the button positioned in the window's right edge is pressed, list-box is extended. that is very marvelous and interesting to me.
let me know how to do i implement that.
thank you
have a nice day
|
|
|
|
|
Can anyone help me figure out how to make code for a server type of program...I want users to be able to log into my computer and play a game and I have no clue where to start with the coding of the client/server connection...So any help would be greatly appreciated.
Thanks in advance.
|
|
|
|
|
If you want to use winsock have a look at the GlobChat sample that comes with the Platform SDK (can also be found at MSDN). It's a multiprotocol chat server that shows how to set up the basic structure of a winsock client/server application.
|
|
|
|
|
Anyone can tell me where I can find the C/C++ source code on how page and buffer manager
are implemented in a database system?
Thank you
|
|
|
|
|
Does anyone know where I can find some tutorials on how to create a side control panel. A side control panel like the one found on MS-Paint. There is a Dialog like control that is attached to the left or right side of the main view.
|
|
|
|
|
|
Yes I'm using MFC. Will CDialogBar create a Side menu like device on the side of my main window.
|
|
|
|
|
|
Sorry, just trying to show someone how to sign up. Thought I could delete this, but cannot.
|
|
|
|
|
I would like to create a CBitmap object from a DC, then draw the bitmap on each successive repaint rather than doing all the drawing stuff again (there is quite a lot, which is why I want to use this approach).
So, I know how to blit the CBitmap back to the DC each time the window is repainted, but I don’t know how to copy the stuff I’ve drawn to the DC into the CBitmap. How would I do this?
Thanks in advance for any help you can give me.
Yours,
James Millson
|
|
|
|
|
Once I've create a function CopyBitmap(..) to copy a bitmap form one to another. Note that it does not work on all kind of bitmaps (eg 32-bits not ). You should be able to find the way to copy the image from your DC to a CBitmap. Hint: iso SourceDC use your own pointer to DC in the function BitBlt(..). Have fun!
Kit
BOOL
CBetterBitmap::CopyBitmap
(
CBitmap* pbmpSource, // IN: Source bitmap
CBitmap* pbmpDest // OUT: Target bitmap
)
{
BOOL bResult = FALSE;
// Invalid source bitmap
ASSERT(pbmpSource != NULL);
// pbmpDest must point to an existing CBitmap instance
ASSERT(pbmpDest != NULL);
ASSERT(pbmpDest->GetSafeHandle() == NULL);
// Quick pointer verification
if ( (pbmpSource != NULL) &&
(pbmpDest != NULL) )
{
BITMAP bmp;
pbmpSource->GetBitmap(&bmp);
// First copy the bitmap information
if (pbmpDest->CreateBitmapIndirect(&bmp))
{
CDC SourceDC;
CDC DestDC;
// Now copy the bitmap via display compatible DC's
if ( (SourceDC.CreateCompatibleDC(NULL) != FALSE) &&
(DestDC.CreateCompatibleDC(NULL) != FALSE) )
{
CBitmap* pbmpPrevSrc = SourceDC.SelectObject(pbmpSource);
CBitmap* pbmpPrevDest = DestDC.SelectObject(pbmpDest);
bResult = DestDC.BitBlt(0, // Source Left
0, // Source Top
bmp.bmWidth, // Source Width
bmp.bmHeight, // Source Height
&SourceDC, // Source DC
0, // Target Left
0, // Target Top
SRCCOPY); // Raster Operation
DestDC.SelectObject(pbmpPrevSrc);
SourceDC.SelectObject(pbmpPrevDest);
}
}
}
// Return result
return bResult;
}
|
|
|
|