|
I am creating an email client which needs to supports S/MIME . For this purpose I am using IP*Works Library. (IP*Works "SPOP" C++ Class for receiving the mails with S/MIME (Digitally signed mails.)
After receiving the digitally signed mail we needs to store the digital certificate of the sender to windows certification store just like outlook express (When a digitally signed mail is received by outlook express it stores the attached certificated in the windows certificate store and attached the certificate with public key to windows address book.)
Using IP Works I am able to get the full text of the certificate send with the digitally signed mail. but the certificate has only key public key (as i am the receiver of the mail).
Could someone suggest some API for storing the certificate with public key to windows certification store?
I has tried searching windows Crypto API but can't find any information regarding storing certificate with public key to windows certification store.
Any help would be appreciated.
|
|
|
|
|
Given a HWND, is there a reliable way or API to detect if it's a full screen window?
I was trying the following
HWND deskWnd= GetDesktopWindow();
RECT deskRect;
GetWindowRect(deskWnd, &deskRect);
HWND topWnd = GetTopWindow(NULL);
RECT topRect;
GetWindowRect(topWnd, &topRect);
But sometimes the topRect's top, bottom, left and right values are all negative, or represent a smaller rect than deskRect even though topWnd is indeed a full screen window.
I've also tried with GetForegroundWindow instead of GetTopWindow, but still no affirmative result.
Anyone knows how? Thanks.
|
|
|
|
|
Try GetWindowPlacement.
WINDOWPLACEMENT wp;<br />
wp.length = sizeof(WINDOWPLACEMENT);<br />
::GetWindowPlacement(topWnd, &wp);<br />
<br />
if ( wp.showCmd == SW_SHOWMAXIMIZED )<br />
{<br />
}<br />
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Unfortunately, it doesn't quite work because sometimes topWnd doesn't point to the correct window.
I've tried the following:
BOOL IsFullScreenAppRunning(HWND excludeWnd)
{
TCHAR tempStr[1028] = {0};
TCHAR windowTitle[512] = {0};
int result = 0;
int index = 0;
HWND firstWnd = GetForegroundWindow();
HWND nextWnd = GetNextWindow(firstWnd, GW_HWNDNEXT);
GetWindowText(excludeWnd, windowTitle, 512);
_stprintf_s(tempStr, _T("excludeWnd window title: %s\n"), windowTitle);
OutputDebugString(tempStr);
while ((nextWnd != NULL) && (result < 1))
{
_stprintf_s(tempStr, _T("loop %d)\n"), index);
OutputDebugString(tempStr);
GetWindowText(nextWnd, windowTitle, 512);
_stprintf_s(tempStr, _T("window title: %s\n"), windowTitle);
OutputDebugString(tempStr);
if ((nextWnd != excludeWnd) && IsWindowVisible(nextWnd) && !IsIconic(nextWnd) && IsZoomed(nextWnd))
{
result++;
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
::GetWindowPlacement(nextWnd, &wp);
_stprintf_s(tempStr, _T("full screen showCmd: %d\n"), wp.showCmd);
OutputDebugString(tempStr);
RECT fullRect;
GetWindowRect(nextWnd, &fullRect);
_stprintf_s(tempStr, _T("full screen rect top: %d, left: %d, bottom: %d, right: %d\n"), fullRect.top, fullRect.left, fullRect.bottom, fullRect.right);
OutputDebugString(tempStr);
GetWindowText(nextWnd, windowTitle, 512);
_stprintf_s(tempStr, _T("full screen window title: %s\n"), windowTitle);
OutputDebugString(tempStr);
}
index++;
nextWnd = GetNextWindow(nextWnd, GW_HWNDNEXT);
}
return (result > 0);
}
It also doesn't quite work. When there is a full-screen window, it can find it correctly, but when there isn't, it tends to find a regular maximized window. So, I still don't have the solution yet.
|
|
|
|
|
Hi,
I am trying to handle the wm_move or wm_moving message to keep a window within a bounding box, I am not able to stop the message from propagating once I'm done with it.
What do I need to do??
I have been messing around with this code.
Code no good, don't use :P
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
int xMin = 30, xMax = 400;
int yMin = 20, yMax = 400;
int charCount = 0;
int posX=0, posY=0;
int ret = 0;
RECT trect= { 0, 0, 0, 0 };
LPRECT rect =& trect;
switch(Msg)
{
case WM_PAINT:
ret = 0;
case WM_MOVING:
SetWindowPos(hWnd, HWND_TOP, 0, 0, 200, 200, SWP_NOSIZE | SWP_NOMOVE );
GetWindowRect( hWnd, rect );
if ( rect != NULL )
{
if ( rect->left > xMax )
posX = xMax;
if ( rect->left < xMin )
posX = xMin;
if ( rect->top > yMax )
posY = yMax;
if ( rect->top < yMin )
posY = yMin;
if ( posX > 0 || posY > 0 )
SetWindowPos( hWnd, HWND_TOP, 10, 10, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE );
}
break;
case WM_MOVE:
ret = WM_MOVE;
counter ++;
char buffer2[200];
sprintf( buffer2, "%d MOVE MESSAGES SO FAR.", counter );
charCount = SetWindowText( hWnd, buffer2 );
break;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return ret;
}
-- modified at 22:39 Thursday 21st September, 2006
|
|
|
|
|
beeejay wrote: What do I need to do??
Well here is a small code snippet which restricts the movement of a child dialog within it's parent dialog, may be this will help you..., this is MFC , you will have to do something similar in SDK.
void CCNonClippingChildDlg::OnMoving( int nSide, LPRECT lpRect )
{
static RECT rcPreviousCoords = *lpRect;
CWnd *pParentDlg = GetParent();
if( !pParentWnd )
return;
CRect crParentRect;
pParentDlg->GetClientRect( &crParentRect );
pParentDlg->ClientToScreen( &crParentRect );
if( lpRect->left <= crParentRect.left || lpRect->right >= crParentRect.right )
{
lpRect->left = rcPreviousCoords.left;
lpRect->right = rcPreviousCoords.right;
}
else
{
rcPreviousCoords.left = lpRect->left;
rcPreviousCoords.right = lpRect->right;
}
if( lpRect->top <= crParentRect.top || lpRect->bottom >= crParentRect.bottom )
{
lpRect->top = rcPreviousCoords.top;
lpRect->bottom = rcPreviousCoords.bottom;
}
else
{
rcPreviousCoords.top = lpRect->top;
rcPreviousCoords.bottom = lpRect->bottom;
}
}
I handled the WM_MOVING message.
|
|
|
|
|
Ok i tried somthing similiar but the window is being drawn in my location and then in the location it would be had I not interfered.
How are you calling this within the wndProcedure? Is there a window callback in mfc as there is in win32?
Thanks
|
|
|
|
|
beeejay wrote: Ok i tried somthing similiar but the window is being drawn in my location and then in the location it would be had I not interfered.
It's working fine in MFC .
beeejay wrote: How are you calling this within the wndProcedure? Is there a window callback in mfc as there is in win32?
In WindowProc you will have to do something like
LRESULT WindowProc( ... )
{
switch( message )
{
case WM_MOVING:
OnMoving( ... );
}
DefWindowProc( ... );
}
In the previous given function you will have to convert functions from MFC to SDK format. Like passing the HWND as the first parameter as required, rest will be ok...
For eg:
::GetParent( hWndChild );
|
|
|
|
|
OK it doesn't look like there is an OnMoving function within the SDK. would your program function the same way if you were just to paste the contents of your method into the WM_MOVING case?
Thanks Alot,
Ben
|
|
|
|
|
beeejay wrote: OK it doesn't look like there is an OnMoving function within the SDK.
Heh, when did I say that . I was just calling that function when the event WM_MOVING happens, in order to isolate the code.
beeejay wrote: would your program function the same way if you were just to paste the contents of your method into the WM_MOVING case?
It won't. As I said you will have to convert MFC to SDK.
For eg: GetParent( hWndChild );
Anyway here is the SDK code and don't tell me again it doesn't work...;)
case WM_MOVING:
{
LPRECT lpRect = ( LPRECT )lParam;
static RECT rcPreviousCoords = *lpRect;
HWND pParentWnd = ::GetParent( hWnd );
if( !pParentWnd )
break ;
RECT crParentRect;
::GetClientRect( pParentWnd, &crParentRect );
::ClientToScreen(pParentWnd, (LPPOINT)&crParentRect);
::ClientToScreen(pParentWnd, ((LPPOINT)&crParentRect)+1);
if( lpRect->left <= crParentRect.left || lpRect->right >= crParentRect.right )
{
lpRect->left = rcPreviousCoords.left;
lpRect->right = rcPreviousCoords.right;
}
else
{
rcPreviousCoords.left = lpRect->left;
rcPreviousCoords.right = lpRect->right;
}
if( lpRect->top <= crParentRect.top || lpRect->bottom >= crParentRect.bottom )
{
lpRect->top = rcPreviousCoords.top;
lpRect->bottom = rcPreviousCoords.bottom;
}
else
{
rcPreviousCoords.top = lpRect->top;
rcPreviousCoords.bottom = lpRect->bottom;
}
return TRUE;
}
|
|
|
|
|
Ok I have somthing very similiar, but I am still having the same problem.
The window is drawn twice, once very quickly in my position( and then erased), and then once in position it would be in had i not intervened.
Here is the code for WM_MOVING:
RECT rect;
GetWindowRect( hWnd, &rect );
if ( rect.right > xMax )
rect.left = xMax - ( rect.right - rect.left );
if ( rect.left < xMin )
rect.left = xMin;
if ( rect.bottom > yMax )
rect.top = yMax - ( rect.bottom - rect.top );
if ( rect.top < yMin )
rect.top = yMin;
SetWindowPos( hWnd, HWND_TOP, rect.left, rect.top, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE );
return true;
Thanks alot
|
|
|
|
|
beeejay wrote: SetWindowPos( hWnd, HWND_TOP, rect.left, rect.top, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE );
Well this is the problem, you don't have to do this...
Why don't you try the code that I gave, and try to see the difference.
|
|
|
|
|
I was missing this little gem LPRECT lpRect = ( LPRECT )lParam;
Thanks alot,
It seems that the rect which GetWindowRect sets doesn't actually get used after my WM_MOVING hanlder is complete.
|
|
|
|
|
beeejay wrote: It seems that the rect which GetWindowRect sets doesn't actually get used after my WM_MOVING hanlder is complete.
Read what MSDN says about lParam as on WM_MOVING event...
<code>lParam: </code>
Pointer to a <code>RECT </code>structure with the current position of the window, in screen coordinates.
<code>To change the position of the drag rectangle, an application must change the members of this structure.</code>
|
|
|
|
|
I need to learn fast about the creation of ATL Composite Control Projects.
Where could I find abundant information about this??.
Maybe a tutorial in the WEB.
Maybe a book.
I have read a lot about ATL projects but I need something specific about Composite Controls. Something that teach me how should I move inside this kind of project.
I have some good skills with MFC and I'm learning general ATL stuff.
Thank you very much.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
|
Did you see C++ Libraries On codeproject
|
|
|
|
|
hi good day to everyone. why do i have this kind of warning to my functions?
warning C4100: 'nFaceRecNo' : unreferenced formal parameter
what does it mean? thanks for your reply
positive vibes
|
|
|
|
|
It means that the parameter "nFaceRecNo " isn't used in the function. The best way to get rid of this warning is as follows:
void Foo(int n)
{
}
void Foo(int)
{
}
Note that in the code without the warning I've removed any parameters which I don't use in the function from the function definition. It can still be present in the declaration. There are other ways of resolving this problem but this is how I normally deal with it.
Steve
|
|
|
|
|
thanks so much steve... problem solved here
positive vibes
|
|
|
|
|
We have several VC7 MFC and ATL applications and are wondering whether to port them over to VC8. The main reason is so that we don't have a mix of development environments - some projects using vs2003 and some using vs2005.
But are there any advantages as far as the libraries go - STL/ATL/MFC? I understand the main change is in the C runtime string functions to reduce buffer overflow problems. Any other changes for better or worse?
|
|
|
|
|
Yes, basically if you use C string functions, you'll get a warning. Beyond that, I see no compelling reason to change, there are some breaking changes for standards, but all reasonably obscure.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sir,
I want to learn how to make a web application in vc++.net.
Please send any link .
Thanks.
|
|
|
|
|
I don't believe you can use C++ for ASP.NET. Your profile says you know ASP.NET, why do you want to write a web app in c++ ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi..
Is there a way to prevent a file from being opened in windows ....
The System is not a part of any network..
There is No other users except Administrator is available in the system.
Thanks
Luck is Opportunity with hardwork
|
|
|
|
|