|
I wrote the following code, but it give me a red screen, everything become red-like, not gray.
CWindowDC dc(NULL);
for ( int i=0; i<1024; i++)
for ( int j=0; j<768; j++)
{
COLORREF clr = dc.GetPixel(i, j);
int R = GetRValue(clr);
int G = GetGValue(clr);
int B = GetBValue(clr);
clr = (54 * R + 183 * G + 19 * B)/256;
//clr = 0.299 * B + 0.587 * G + 0.114 * R;
//.299 * red + .587 * green + .114 * blue
dc.SetPixel(i, j, clr);
}
What I needed maybe you have, so let's help each other.
|
|
|
|
|
You need to write something like this:
int newclr = (54 * R + 183 * G + 19 * B)/256;
clr = RGB(newclr, newclr, newclr)
to put data in all three channels.
|
|
|
|
|
Thanks, I have correctted it.
But there still has a problem:
some area also is colourful, not gray, such as title bar, part of task bar.
What I needed maybe you have, so let's help each other.
|
|
|
|
|
Please stop saying
What I needed maybe you have, so let's help each other
it sounds so mercenary. I help people to help them, I'm sure others here do the same and it is a given that you will probably help me if you can later on.
Anyhow, these areas are drawn by windows, you won't be able to draw on them using this method. The mouse pointer is the same. What is happen is that GDI allows you to draw out of bounds without a crash it just ignores the call. BTW you should add code to check the screen size to your loop - use GetSystemMetrics to do that.
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.
|
|
|
|
|
I should also mention that the reason I suggested copying to a DIBSection is that GetPixel is painfully slow compared to iterating through the bits using the pointer a DIBSection's constructor gives you.
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.
|
|
|
|
|
Is there is any who can help me to remove the scroll bars from the Html View Window?...;)
|
|
|
|
|
I can't tell you the script off hand, but add the JavaScript to your document which tells the window to hide the scrollbars. That will work.
David Wulff
dwulff@battleaxesoftware.com
|
|
|
|
|
Sir,
I am using Visual C++ and then I have created the HTML view on the Dialog , in which i have forced the HTML window to display my own HTML text. but there is one problem when we load the text in the window if the text is more than the length of the window then Scrolling is visible i want to disable that scroll bar...
|
|
|
|
|
Hey all!!
You know when you right click on the CD Drive icon in my computer, you have the option of ejecting the cd? How do I do this in my MFC dialog app?
Thanks
Ashman
|
|
|
|
|
Search in MSDN for thread Q81871. There's a link to a sample application. Perhaps it will help you.
Gero Gerber
|
|
|
|
|
I have need to add 2 radio buttons to the print dialog and/or the Print setup dialog. I have no problem supplying my own template for the Print dialog and then passing the additional data back to the print function.
However when it comes to the Print Setup the template does not work, the dialog does not come up.
Also if the printers properties are changed I need to have these controls informed of that.
I'm trying to get out of having to write the entire thing myself.
Happy programming!!
|
|
|
|
|
I've always found this to be a disaster. I got around it by rolling my own dialog which has a preview, controls for choosing page layout and a button that brings up the traditional printer to choose if you want to change printers. I bring it up in OnPrint.
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.
|
|
|
|
|
Hi there,
Please help me, I have been so frustrated. I am working on a Win32 DLL. Inside the dll, I am trying to create a popup window which is hidden and covers the entire desktop so I can process mouse message across the screen and do rubber banding. I am doing this because of the restriction of SetCapture(HWND hwnd) API.
What I can do now is that as soon as the client loads the DLL, a hidden window will be created and mouse messages will be processed in GrabProc Callback function. Instead of creating the hidden window when the dll is first loaded, I am hoping to create a hidden window when the mouse is down and destroy it when the mouse it up.
I am a newbie on Windows Programming. Would someone please give me some pointers and show me how to accomplish what I need. Thank you very much for your help.
BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
CreateHiddenWindow();
}
}
BOOL CreateHiddenWindow()
{
static TCHAR szAppName[] = TEXT ("Test") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = GrabProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = g_hInstance ;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindowEx(WS_EX_TRANSPARENT,
szAppName, NULL,
WS_POPUP, 0, 0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
NULL, NULL, g_hInstance, NULL);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK GrabProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
// Handle mouse down, move, up messages for entire screen
// rubber banding
switch (message)
{
case WM_LBUTTONDOWN:
// Create hidden window
break;
case WM_MOUSEMOVE:
break;
case WM_LBUTTONUP:
// Destroy hidden window
break;
}
};)
|
|
|
|
|
Is it possible to specify a non Windows' control when deriving a class from CCtrlView? Ideally I would like to specify the class name of my CWnd derived class. I have tried, but it always fails.
Cheers,
James Millson
|
|
|
|
|
What do you mean by "it fails"? It doesn't compile? It crashes?
--Mike--
http://home.inreach.com/mdunn/
We've secretly replaced the msdn.microsoft.com servers with Atari 800XLs. Let's see if anyone notices....
|
|
|
|
|
I get the "Cannot create blank document" message.
Cheers,
James Millson
|
|
|
|
|
subj.
I try:
void CTest::OnPaint()
{
CPaintDC dc(this);
CMemDC memdc(&dc);
CRect clip;
memdc.GetClipBox(&clip);
memdc.FillSolidRect(clip, GetSysColor (COLOR_3DLIGHT));
DefWindowProc(WM_PAINT, (WPARAM)memdc->m_hDC, (LPARAM)0);
}
BOOL CTestDlg::OnEraseBkgnd(CDC* pDC)
{
return FALSE;
}
but anyway my *picture control* flickering and after max/min window's size flicks too. Even more when I open any file by CFileDialog my controls aren't repainted.
What's wrong?
|
|
|
|
|
For a start, handle WM_ERASEBKGND, not WM_PAINT.
--Mike--
http://home.inreach.com/mdunn/
We've secretly replaced the msdn.microsoft.com servers with Atari 800XLs. Let's see if anyone notices....
|
|
|
|
|
Move all WM_PAINT code to WM_ERASEBKGND? or what?
|
|
|
|
|
Yes. Since you are painting a custom background color, do it in WM_ERASEBKGND.
--Mike--
http://home.inreach.com/mdunn/
We've secretly replaced the msdn.microsoft.com servers with Atari 800XLs. Let's see if anyone notices....
|
|
|
|
|
>We've secretly replaced the msdn.microsoft.com servers with Atari 800XLs. Let's see >if anyone notices....
I thought MSDN online seemed a bit quicker than normal!
|
|
|
|
|
Micahel is absolutely right, but I'll also point out that when you call CPaintDC the screen is blanked, so if you ever have to draw anything in OnPaint and have trouble with flicker, don't create your PaintDC until you're about to copy the memDC over the top of it. Otherwise you may stop tearing, but you won't do a thing about flicker.
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.
|
|
|
|
|
I don't understand this piece of code...
Where do you get CMemDC from? I don't have it?
Also, why are you not calling BitBlt to eliminate flickering?
Thx,
/Tommy
|
|
|
|
|
Hello,
Im having some troubles with CString commands.. I have a text file that I am opening with CFile and reading into a CString called strSource... There is a line in the text file like this for example (This is a line in line of text in my "text file" test test) ..
Im trying to search the CString strSource and find "my" then pull the information out of the "" just to the right of "my".. so that I end up with a string with a value of "text file".. in this text file "my" is a unique line of text..
Thanks in advance for you help!
Rob
Rob Jones
|
|
|
|
|
Nothing terribly difficult about it
int nMyIndex, nFirstQuoteIndex, nSecondQuoteIndex;
nMyIndex = strSource.Find ( _T("my") );
nFirstQuoteIndex = strSource.Find ( '"', nMyIndex );
nSecondQuoteIndex = strSource.Find ( '"', nFirstQuoteIndex+1 );
CString strFilename = strSource.Mid ( nFirstQuoteIndex+1, nSecondQuoteIndex-nFirstQuoteIndex-1 ); Naturally, error-checking would be a Good Thing to add to this.
--Mike--
http://home.inreach.com/mdunn/
We've secretly replaced the msdn.microsoft.com servers with Atari 800XLs. Let's see if anyone notices....
|
|
|
|