|
the codes are as follows:
APPBARDATA abd;
abd.cbSize = sizeof(APPBARDATA);
abd.uEdge = ABE_RIGHT;
abd.lParam = TRUE;
abd1.hWnd = m_hWnd;
if(!SHAppBarMessage(ABM_SETAUTOHIDEBAR, &abd))
AfxMessageBox("Register failed");
It's a dialog based application and the return value shows that registration succeeds.But the window has no auto-hide effect.Please tell me why?
Thank you.
Thanks for your answer.
|
|
|
|
|
At the end of debugging, the debugger is showing me:
Detected memory leaks!
Dumping objects ->
{44} normal block at 0x00BC2638, 33 bytes long.
Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD
{43} normal block at 0x00BC25D0, 40 bytes long.
Data: < |L > 14 7C 4C 10 16 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
Looking at above signals, how can i find out that which part of my code is causing memory leakage. To my best knowledge i've not used "new" anywhere, still the debugger is giving these things.
|
|
|
|
|
You will need to use _CrtSetDbgFlag and _CrtSetBreakAlloc.
Magnus
|
|
|
|
|
Hi all
how i can retrieved thread handle from ID one
Thanks
|
|
|
|
|
If you mean you have a thread ID, and you want a thread handle, look up OpenThread .
|
|
|
|
|
Thanks.
But OpenThread only for Win2000 or i wrong??
And else how i can recognize which thread launch current thread.
Actually i want create COM object which will be able suspend
clients thread.
|
|
|
|
|
Try to encrpt something, using CryptAcquireContext, unfortunately, return value==0 for everycall. I called GetLastError trying to figure out what exactly was the error, but it was a very big negative number - and no error code should be negative???
I moved to dot net for a while, I don't remeber how to link to a library (don't want to bother LoadLibrary). I checked MSDN documentation:
Header: Declared in Wincrypt.h.
Library: Use Advapi32.lib.
But I think that shouldn't be the reason why I'm getting this weird big/negative error code right?
Anyway, here's my code - it's so simple i have no idea what's wrong with it:
#include "stdafx.h"
//For screen dump:
//#include <stdio.h>
//************************//
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <wincrypt.h>
#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
#define MS_DEF_PROV "Microsoft Base Cryptographic Provider v1.0"
#define PROV_RSA_FULL 1
//************************//
int _tmain(int argc, _TCHAR* argv[])
{
BOOL bResult;
HCRYPTPROV hProv=NULL; //handle to CSP
bResult = CryptAcquireContext(
&hProv, // Variable to hold returned handle.
NULL, // Use default key container.
MS_DEF_PROV, // Use default CSP: "Microsoft Base Cryptographic Provider v1.0"
PROV_RSA_FULL, // Type of provider to acquire.
0); // No special action.
if(bResult==0) {
//
printf("Error: STEP 1. Error code: %d\n", GetLastError());
}
else
{
printf("Retrieve handle to provider success.\n");
}
return 0;
}
norm
|
|
|
|
|
When displaying an error code returned from GetLastError , remember that it's a DWORD and hence is unsigned.
You got a big negative number because bit 31 in the return code is set.
I suggest displaying it as hex (using the %x format string).
You shouldn't be defining MS_DEF_PROV or PROV_RSA_FULL . You should use the definitions in WinCrypt.h .
|
|
|
|
|
Mike Dimmick wrote:
You shouldn't be defining MS_DEF_PROV or PROV_RSA_FULL. You should use the definitions in WinCrypt.h.
I commented them out - but the exact same code run on another machine running WIN2003 - no problem. I am not sure if this has anything to do with XP installation...?? I checked MSDN, CryptAcquireContext should work with XP and:
#define _WIN32_WINNT 0x0400
?? I ran it on XP. CryptAcquireContext return 1 - which indicates things are okay.
norm
|
|
|
|
|
For a technical drafting program, i need to draw truetype fonts with total control on their height : for example i want a text of exactly 10mm high.
The problem is in interpretation of height; for truetype fonts, this height is made of 3
parts : Descent (part under the baseline), Ascent (part over the baseline), InternalLeading (some space above the character). All these values are returned by
pDC->GetTextMetrics() when you have selected a font in the pDC.
In my case the height includes only the ascent part : when i say i want a font 10 mm high, it means a font whose characters above the baseline (such as digits) will be 10 mm high. This convention is used by programs such as Autocad, MicroStation, ...
For creating a CFont object, you have to fill a LOGFONT struct with the properties of the font, such as font name, height, weight, ... But as said before, the height here include descent + ascent + leading. Here is how i try to get what i want :
CFont *pOldFont, newfont;<br />
TEXTMETRIC Metrics;<br />
LOGFONT lf;<br />
memset(&lf, 0, sizeof(LOGFONT));<br />
strcpy(lf.lfFaceName, "Arial");<br />
lf.lfHeight = - (long)FontSizeInPixels;
<br />
...
newfont.CreateFontIndirect(&lf);<br />
pOldFont = pDC->SelectObject(&newfont);<br />
pDC->GetTextMetrics(&Metrics);
<br />
<br />
lf.lfHeight = -(long) FontSizeInPixels * (FontSizeInPixels / (Metrics.tmAscent - Metrics.tmInternalLeading));<br />
<br />
<br />
<br />
newfont.Detach();<br />
newfont.DeleteObject();<br />
newfont.CreateFontIndirect(&lf);
pDC->SelectObject(&newfont);<br />
pDC->GetTextMetrics(&Metrics);<br />
ASSERT(fabs(Metrics.tmAscent - Metrics.tmInternalLeading - FontSizeInPixels) < 2);<br />
Problem : although the ASSERT above is ok for all the fonts i tried, the resulting height on screen is near the required height but there is still an error up to 20 %; for a same specified height, some fonts are smaller, some are bigger.
JPG
|
|
|
|
|
Hi,
i have a MFC Dialog with a CPropertySheet in it. The CPropertySheet is made of 3 CPropertyPages, and one the these Pages holds a button, which, if pressed shall activate another CPropertyPage. Until now, i realized it in a very ugly way. I have stored the pointers of the CPropertySheet and the Page ,which should be activted, at OnInitDialog(). But there must be an easier way to do this. I need this pointers in a functionen which depends to that CPropertyPage, holding the Button. Does there a function extist, which can bring me the pointer of the CPropertySheet?
Thanks in advance!
|
|
|
|
|
CPropertySheet* pSheet = (CPropertySheet*)GetParent();
ASSERT_KINDOF(CPropertySheet, pSheet);
Then pSheet will be having the Ans for ur query
Thanx
TAKE CARE
|
|
|
|
|
Hi all,
Can anybody know how to restrict to type fixed number of characters in the CEdit control.
Thanks.
The Phantom.
|
|
|
|
|
open Class Wizard and assign a CString variable for your edit and you will see "Maximum characters" in the lower part of the Class Wizard. Set there how many characters your CString wants to have.(same for int, long...)
|
|
|
|
|
if u want to assign a CEdit ctrl as the data member to the Edit Ctrl then u can call the function-->>
EditCtrl.SetLimitText(VALUE_of_memeber_u_want );
i hope this solve ur query
Thanx
TAKE CARE
|
|
|
|
|
Hmmm.... is there an analgous way to restrict what is types? For example, suppose I only want to allow alphanumeric english letters in the editbox.... Or does that require subclassing?
|
|
|
|
|
Use the CEdit::SetLimitText() . You can use DDX for this but it's better to restrict the text length as you are typing rather than wait until the OK button has been clicked (i.e., validating in the OnOK() handler is too little too late).
|
|
|
|
|
Hi!
I am wondering how I can copy files in the current exe folder to a folder like C:\files\ which doesnt exist!
Thank you for your future answers!
Well... I am a beginner ...
|
|
|
|
|
You can use the CreateDirectory function to create your target directory, followed by CopyFile to copy the files.
|
|
|
|
|
Or you can use the SHFileOperation function (which also supports recursive copying) to copy. See the following MSDN page[^] for more detailed information.
|
|
|
|
|
Hello guys,
I want to generate Ctrl-Alt-Del key sequence programmatically.
I have searched a lot on net but don't get any solution.
I have tried to fill keyboard buffer with 'keybd_event()' function. But it is also not working. It seems that it fills application's key buffer.
Anyway......can anybody help me to solve this problem ?
Thanking You,
C.R.Naik
|
|
|
|
|
It's not an easy one to solve. That key combination is special. When you press the Ctrl+Alt+Del keys on the keyboard, the keyboard driver is detecting that and passing the instructions on to the OS, rather than any application(s). Trying to stuff the keyboard buffer does not get "low enough" in the hierarchy.
These two articles don't directly answer your question, but they might help you get started:
http://www.codeproject.com/useritems/preventclose.asp
http://www.codeproject.com/useritems/GINA_SPY.asp
|
|
|
|
|
Hi,
how are the big buttons done in the add/remove programs on XP?
they look great and i would like to use them.
any ideas how to do something like it or has anyone done it?
what would you call it? just buttons? listbar?
thx
|
|
|
|
|
According to Spy++, the buttons are part of the DirectUI window classes. I've not found any good information on this stuff sadly. (Probably more undocumented API's)
However you can easily simulate the effect using
http://www.codeproject.com/buttonctrl/cbuttonst.asp[^]
or
http://www.codeproject.com/buttonctrl/cxpstylebuttonst.asp
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
Hi,
can i use the new VS. Net IDE to write and compile my old mfc42 code without converting it to mfc7??
where and what do i have to setup?
and of course i still want to write mfc7 code as well... would there be a way to choose the settings on startup?
thanks guys
|
|
|
|