|
dipuks wrote: Now i want to disable the app controls when the Disk Defragmenter is OPEN and
then re-enable the app controls when Disk Defragmenter is CLOSED.
How to
do this?
Do you have a handle to the window?
dipuks wrote: I am using ShellExecute function to open the Disk Defragmenter. I can know when
the Disk Defragmenter is OPENED, but not when it's CLOSED. Is that true?
Look at the PROCESS_INFORMATION structure. Monitoring those handles or IDs should provide you this information.
dipuks wrote: If i am right CreateProcess() function can't be used in this case, as Disk
Defragmenter needs Admin privilages to open.
Can you use CreateProcessAsUser() or CreateProcessWithLogonW() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
|
Thank you guys.....i Did it!
|
|
|
|
|
Ok, so here is the thing. I got a window, simple win32 window with a black background which was applied with FillRect function to fill whole client rectangle with black color. Now i am trying to paint some picture on this window with StretchBlt. Basically, here is my function:
void PaintBkgImage(__in HWND hWnd,
__in HDC PaintDC,
__in BITMAP bmp,
__in HDC prevDC,
__in int StretchFromLeft,
__in int StretchFromRight,
__in int StretchFromTop,
__in int StretchFromBottom)
{
SetStretchBltMode(PaintDC, HALFTONE);
StretchBlt(PaintDC,
StretchFromLeft,
StretchFromTop,
_client_rect.right,
_client_rect.bottom - StretchFromBottom,
prevDC,
StretchFromRight,
0,
bmp.bmWidth,
bmp.bmHeight,
SRCCOPY);
}
and now StretchFromLeft = 10 for example, so the pic should be stretched from left by 10 units. Ok, StretchBlt does this, but it leaves a nasty white rectangle on left side. Same thing with any other parameter =/
I have tried filling window with black color yet again but it has no effect at all after calling StretchBlt. How can i make it work? So basically i need my window to remain black and only picture should be stretched from every side (left , right, bottom ,top)?
Thanks
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
The second parameter of StretchBlt (StretchFromLeft in your code) is the x-offset in destination dc. So, no surprise you're getting a margin on left.
|
|
|
|
|
Margin on left is what i need to get, as well as margin on right , margin from top and bottom. And my code is fine, the deal here was a white rectangle, but after some look into it, - there was a need to paint over these white rects inside wm_paint, while i was painting over in wm_erasebkg and that was the mistake.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Do you paint your background inside the WM_PAINT handler?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yup, image is drawn in wm_paint, and filling with black goes in WM_ERASEBKGND.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
You might have to call InvalidateRect for the area that is exposed by the StretchBlt call.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Alright, i got it. The deal is actually to erase these while fields in wm_paint after call StretchBlt
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Hi, I want to use AlphaBlend() method to display transparent shadow. I requires some sort of calculation to mix color value from bitmap( for which I have to display shadow ) with other color( shadow color ).
I have referred caculation method from msdn it's not giving me proper result. I am giving the code. Pls help me out.
DWORD destRedColor = 0;
DWORD destBlueColor = 0;
DWORD destGreenColor = 0;
DWORD destAlphaColor = 0;
DWORD SrcRedColor = 0;
DWORD SrcBlueColor = 0;
DWORD SrcGreenColor = 0;
DWORD SrcAlphaColor = 0;
int src_const_alpha = 0;
for ( int i = ( ( bm.bmWidth * bm.bmHeight ) - 1 ); i >= 0; --i )
{
COLORREF clrRef = ptPixels[i];
clrRef = COLORREF2RGB( clrRef );
DWORD redDest = GetRValue( clrRef );
DWORD greenDest = GetGValue( clrRef);
DWORD blueDest = GetBValue( clrRef);
BYTE *ptrAlphaDest = reinterpret_cast<BYTE*>( &clrRef );
DWORD alphaDest;
alphaDest = ptrAlphaDest[0];
DWORD redSrc = GetRValue( _cNewColor );
DWORD greensrc = GetGValue( _cNewColor );
DWORD blueSrc = GetBValue( _cNewColor );
BYTE *ptrAlphaSrc = reinterpret_cast<BYTE*>( &_cNewColor );
DWORD alphaSrc;
alphaSrc = ptrAlphaSrc[0];
src_const_alpha = int( m_intensity * 2.55 );
SrcRedColor = redSrc * src_const_alpha / 255.0;
SrcGreenColor = greensrc * src_const_alpha / 255.0;
SrcBlueColor = blueSrc * src_const_alpha / 255.0;
SrcAlphaColor = alphaSrc * src_const_alpha / 255.0;
destRedColor = SrcRedColor + ( 1 - SrcAlphaColor ) * redDest;
destGreenColor = SrcGreenColor + ( 1 - SrcAlphaColor ) * greenDest;
destBlueColor = SrcBlueColor + ( 1 - SrcAlphaColor ) * blueDest;
destAlphaColor = SrcAlphaColor + ( 1 - SrcAlphaColor ) * alphaDest;
ptPixels[i]
= (destAlphaColor << 24 ) |
(destRedColor << 16 ) |
(destGreenColor << 8 ) |
(destBlueColor);
}
modified on Wednesday, March 2, 2011 10:19 PM
|
|
|
|
|
If you do not post any code or indicate the exact problem, all we can help you with is to wish you good luck.
|
|
|
|
|
Hi, I want to use AlphaBlend() method to display transparent shadow. I requires some sort of calculation to mix color value from bitmap( for which I have to display shadow ) with other color( shadow color ).
I have referred caculation method from msdn it's not giving me proper result. I am giving the code. Pls help me out.
DWORD destRedColor = 0;
DWORD destBlueColor = 0;
DWORD destGreenColor = 0;
DWORD destAlphaColor = 0;
DWORD SrcRedColor = 0;
DWORD SrcBlueColor = 0;
DWORD SrcGreenColor = 0;
DWORD SrcAlphaColor = 0;
int src_const_alpha = 0;
for ( int i = ( ( bm.bmWidth * bm.bmHeight ) - 1 ); i >= 0; --i )
{
COLORREF clrRef = ptPixels[i];
clrRef = COLORREF2RGB( clrRef );
DWORD redDest = GetRValue( clrRef );
DWORD greenDest = GetGValue( clrRef);
DWORD blueDest = GetBValue( clrRef);
BYTE *ptrAlphaDest = reinterpret_cast<BYTE*>( &clrRef );
DWORD alphaDest;
alphaDest = ptrAlphaDest[0];
DWORD redSrc = GetRValue( _cNewColor );
DWORD greensrc = GetGValue( _cNewColor );
DWORD blueSrc = GetBValue( _cNewColor );
BYTE *ptrAlphaSrc = reinterpret_cast<BYTE*>( &_cNewColor );
DWORD alphaSrc;
alphaSrc = ptrAlphaSrc[0];
src_const_alpha = int( m_intensity * 2.55 );
SrcRedColor = redSrc * src_const_alpha / 255.0;
SrcGreenColor = greensrc * src_const_alpha / 255.0;
SrcBlueColor = blueSrc * src_const_alpha / 255.0;
SrcAlphaColor = alphaSrc * src_const_alpha / 255.0;
destRedColor = SrcRedColor + ( 1 - SrcAlphaColor ) * redDest;
destGreenColor = SrcGreenColor + ( 1 - SrcAlphaColor ) * greenDest;
destBlueColor = SrcBlueColor + ( 1 - SrcAlphaColor ) * blueDest;
destAlphaColor = SrcAlphaColor + ( 1 - SrcAlphaColor ) * alphaDest;
ptPixels[i]
= (destAlphaColor << 24 ) |
(destRedColor << 16 ) |
(destGreenColor << 8 ) |
(destBlueColor);
}
|
|
|
|
|
Hi all,
the function SetWindowExtEx() is returning false for me sometimes. I am using MM_ANISOTROPIC mapping mode.
GetLastError() is returning error code 50(The request is not supported).
This is happening very rarely and only during print operation.
Can size may be a problem.
|
|
|
|
|
Hi,
I don't know, however what I would do is this:
add some code to log all parameter values and the return value and the GetLastError value (only when it failed!) to a file when it succeeds and when it fails. Looking at those numbers is likely to tell you what is going on.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi
I am using ReadFile with overlapped i\o in synchronous mode. I have 2 questions.
while (true)
{
BOOL b = ReadFile(hSource, &buffer, 200, &k, &ov);
if ((b && k ) == 0)
{
break;
}
ov.Offset = ov.Offset + k;
}
}
The file that program reads is bigger than 200 byte so it must not return EOF. But it does.
When it reads first phase
b = 0 (TRUE), k == 0 which means synchronous read operation gets to the end of a file as described here:
http://msdn.microsoft.com/en-us/library/aa365690%28v=vs.85%29.aspx[^]
My first question is, why does program return EOF even though file 6KB.
My second question is,
I want to read file in a loop as seen here:
ov.Offset = ov.Offset + k;
But i don't understand what is the differences between offset and offsethigh. I mean which one must be increased? I don't really understand the effect of offset and offsethigh. First i thought offset must be beginning and offsethigh is the ending so i must advanced both of them but i think this is not true.
Thanks...
|
|
|
|
|
Hi,
I'm only handling the second question: the file offset once was simply a 32-bit number; later on it had to become a 64-bit number (in order to handle very large files), and MS has chosen to represent such 64-bit number as a struct containing two 32-bit numbers called xyzHigh and xyz. Their combined value equals (xyzHigh<<32)+xyz , so what you need to do is add to the lower part, and if an overflow occurs, add that to the higher part.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I believe the way you're making the check is not right.
For an overlapped operation, no. of bytes read, k in this case will always be 0 .
The actual bytes read is taken using GetOverlappedResult .
Now assume ReadFile returns TRUE , in which case b will be 1 .
So now we have k with a value of 0 and b with a value of 1 , which is a perfect result for an overlapped read.
Consider the check if ((b && k) == 0) .
This translates to if ((1 && 0) == 0) .
Which further translates to if (0 == 0) .
Now this becomes true and the program thinks it has reached EOF.
Here is an excerpt from the documentation on how to check for EOF in a overlapped read operation -
if the file is opened with FILE_FLAG_OVERLAPPED and lpOverlapped is not NULL, the return value is zero (0) and GetLastError returns ERROR_HANDLE_EOF when the file pointer goes beyond the current end of file
|
|
|
|
|
Are you sure that the initial values in your OVERLAPPED structure are correct? Have you checked the error code when ReadFile() returns FALSE ? Lastly, are you sure it is a good idea to use overlapped IO for what is such a simple file read?
I must get a clever new signature for 2011.
|
|
|
|
|
Richard MacCutchan wrote: Lastly, are you sure it is a good idea to use overlapped IO for what is such a simple file read?
Good point, indeed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the answers, I got it.
How can you advance file pointer if you don't use overlapped IO?
|
|
|
|
|
hi
is there any way to filter the only memory leaks which is due to code written by me,not internal code?
Actually what happens ,i caused only 3 memory leaks in my code,but there are 61 memory leaks displayed by the vld.
|
|
|
|
|
There is no such thing as a valid memory leak. IMO you should fix them all.
Are you maybe saying there are false positives? In that case you should report it to the author of the tool.
|
|
|
|
|
If there are internal memory leaks, it is highly likely that you are not using the APIs or functions correctly.
|
|
|
|
|
There is a method to get m_hWnd of dropdown list of CComboBox , of course , except GetComboBoxInfo(...) ?
I need to get that handle to work on Windows NT SP6 , and there I haven't COMBOBOXINFO struct and GetComboBoxInfo ...
I try this[^] method , but is not good for me for two reason :
1. Don't function 'nCtlColor == CTLCOLOR_LISTBOX' part , I don't know why
2. This handle will be avaiable only after I clicked to dropdown button of CComboBox , and I needed in PreSublclassWindow already .
Thank you .
|
|
|
|