|
I've create my own CButton derived class with the BS_OWNERDRAW style. Somehow the button's DrawItem method is not called, and the button is not displayed. When I remove the BS_OWNERDRAW style the button is draw. I'm not getting this, am I'm missing something? This should be simple.
|
|
|
|
|
Did you consider the correct declaration of the function, that means did you declare it as
virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct ) ?
|
|
|
|
|
I did. And I probalby also found the cause of the problem. I copied the code to a simple dialog and it works there. In my current project there are a lot of OnCommand function (I did not write the code) and someting probably goes wrong there.
|
|
|
|
|
I like to autosize the owner draw button depending upon the text that it load dynamically based on localization strings. so some strings are large than others. Keeping this I override DrawItem in the inherited class from CButton.
The sample code is below
void CMyGraphicButton::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CString cs;
CString cslong;
ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
if (!lpszText || lpszText == (LPCTSTR)-1)
{
GetWindowText (cs);
}
else
cs = lpszText;
// now i m trying to resize , so let try to increase the size of button unconditioally
// I get
//lpDrawItemStruct>rcItem.left =0
//lpDrawItemStruct>rcItem.right =75
//lpDrawItemStruct>rcItem.top = 0
//lpDrawItemStruct>rcItem.bottom = 25
//As my button is on extreme right side of dialog so i tried to extend/increase the size of
// button of the left side as follows
lpDrawItemStruct>rcItem.left -= 25 ;
// but the above causes the text to be moved on right side insead of resize/increase the
//button size.
other code here...
Any idea or help is appriciated.
Thanks
Anil
[AKS]
|
|
|
|
|
Hello,
I am trying to set password for a existing user in active directory. I have created user in active directory successfully, and when i am trying to set password using the foloowing code it failes. When i tried calling ADsGetLastError i am not getting any error message or error code. It is showing 0 (Error code) always..
IADsUser *pIADsUser = 0;
try{
hr = ADsGetObject(L"LDAP://CN=prasad,OU=Sales,DC=ads,DC=com",IID_IADsUser,(void**)&pIADsUser);
_variant_t ovar;
hr = pIADsUser->SetPassword(L"prasad");
//hr = pIADsUser->SetInfo();
}
catch(const _com_error *e)
{
_bstr_t bst = e->Description();
}
DWORD dwLastError;
WCHAR szErrorBuf[MAX_PATH];
WCHAR szNameBuf[MAX_PATH];
hr = ::ADsGetLastError(&dwLastError,szErrorBuf,MAX_PATH -1 ,szNameBuf,MAX_PATH-1);//it returns dwLastError = 0
It will be apreciated if anybody can help me...
regards
prasad
|
|
|
|
|
prasadkmadam wrote:
try{
hr = ADsGetObject(L"LDAP://CN=prasad,OU=Sales,DC=ads,DC=com",IID_IADsUser,(void**)&pIADsUser);
if(FAILED(hr))
return hr;
if(!pIADsUser)
return E_FAIL;
_variant_t ovar;
hr = pIADsUser->SetPassword(L"prasad");
//hr = pIADsUser->SetInfo();
}
Could you please make the suggested changes and see if any of the added conditions are true.
P.S. Please, please, please use CComPtr instead of raw pointers.
|
|
|
|
|
Thanks for your reply.
I tried with your suggestions but ADsGetObject() funtion is working fine.
It returned SUCCESS (means 0) and the pIADsUser is having a proper value.
There is no assertion while calling SetPassword() and the call is taking some time also (it seems it contacting the server) but it is returned hr contains some junk value and when i tried calling ADsGetLastError it returned me last error as 0..i dont know what went wrong..
It is not even giving a proper error code..
please help
regards
prasad
|
|
|
|
|
hi All,
I have a form-view app. I have changed the color of the form into blue. i have placed one CStatic control (text) on this form. This control background color is gray. To change this background into the form color(blue), I did subclassing and immplemented "message reflection". But still the CStatic is having gray background. i have written the following code in MyCStatic control class.
// this is the handler for WM_CTLCOLOR message
HBRUSH mystatic::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
pDC->SetBkColor(RGB(0,0,255));
m_brush.CreateSolidBrush(RGB(0,0,255));
hbrush = (HBRUSH) m_brush;
return hbrush;
}
|
|
|
|
|
Did you try handling CTLCOLOR_STATIC inside your form view's OnCtlColor function?
|
|
|
|
|
For colored statics, you may find useful info in these articles:
* Using colors in CEdit and CStatic[^]
* Colored/Blinking Controls and Dialogs with any Font[^]
Using message reflection is the way to do so (ON_WM_CTLCOLOR_REFLECT)
You shouldn't create your brush each time OnCtlColor is called. You could initialized it only once and then pass its handle. Moreover, for each CreateSolidBrush should there be a DeleteObject, or your system will run low for GDI objects.
HTH,
K.
HTH,
K.
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
Hi, thanks alot . Suggestions by both of you helped me really well.
|
|
|
|
|
MAPISendDocuments on Win2K functioned not, with a CreateProcess call by a Printer PortMonitor.
Hello,
I has the following problem:
if I a program normally start and the MAPI function sending document call can I a document by mail dispatch.
if the program startet by a CreateProcess by a PrinterMonitor from a Printer called functions this not and I receive the error message MAPI_E_LOGON_FAILURE
Thanks for answer, K. Bauer
Sorry for my bad english.
|
|
|
|
|
hi coders,
does somebody of you know how to change the IP of a WINNT System in VC++ ??
Thanks
da sonu
|
|
|
|
|
Sonu Kapoor wrote:
IP of a WINNT System in VC++
calling the right API interface?
Really, just entering "IP" into MSDN revealed that IPHelper might be what you want.
From there you can start to follow the references.
Glad to have helped - the only thing need to do yourself is the reading!
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
is there someone who uses TVM_GETISEARCHSTRING?
t!
http://www.codeproject.com/treectrl/rgtree.asp?forumid=2494&exp=0&app=50&select=131468&df=100&tid=131468#xx131468xx
|
|
|
|
|
Hi,
I try to compile this code:
std::sort(actionlist.begin(), actionlist.end(), compareActionlist);<br />
actionlist is a vector.
But i get this error:
error C2039: 'sort' : is not a member of 'std'
I have tried to put using namespace std in the top, but that doesn't help.
Can someone help me? Thanks!
|
|
|
|
|
have you done this:
#include < algorithm >
?
WWT2D?
|
|
|
|
|
Thanks, i get now some other errors but i think i can make it.
|
|
|
|
|
Hi,
Consider a thread function:
MyThreadFunc()
{
<code> Sleep(50000);</code>
return;
}
As can be seen above that my thread blocks in the middle. What i want is that whenever user close my application, all the threads no matter what are they doing should first end gracefully but immediately. But suppose that my thread is stick on some blocking operation as shown in above code. How can i immediately cancel this blocking call and ask the thread to exit properly?? Infact i am using events after every next statements to check their status and exit my threads, but under such situations where the thread is stuck in a long blocking call my application waits like a hell. I want to immediately finish this thread. How ???
Example: In MSN messenger there is an option of cancel sign in . If we select this option then the connecting thread "immediately" stops working. Of course this thread calls various blocking Winsock calls especially for domain resolving, but it ends immediately.
|
|
|
|
|
See WaitForSingleObject in the MSDN and set the event when you want the Thread to stop.
Arjan.
|
|
|
|
|
So what kind of blocking functions are you calling? If you're using Winsock you can create a non-blocking socket and check to see if a connection has been made or a message has been sent/received using the select function. If you want, this select function can 1) not block at all (not recommended) or 2)block for a set amount of time. If you are using sockets I would loop through: telling the select function to block for an undetectable fraction of a second, check to see if the operation has completed, and repeat until the operation either completes, is cancelled, or is timed out.
-Michael Anderson- 完成の円
|
|
|
|
|
My suggestion is to make it appear that the thread exits immediately even though it doesn't. In your MSN message example, how do you know the thread stops immediately? If a dialog box goes away, maybe it wasn't controlled by the blocked thread. After all, how does it respond to your click on "cancel sign in" if the thread is blocked?
Also, are you sure the MSN messenger thread is blocked? Maybe it made an asynchronous call and is processing messages until it gets a reply.
If you absolutely have to have the thread exit immediately, you can call TerminateThread, but read the docs about why it's a bad idea.
|
|
|
|
|
Shah Shehpori wrote:
How can i immediately cancel this blocking call and ask the thread to exit properly?
In addition to the obvious answers you'll get, I thought I'd add a little apparently-not-too-well-known-something.
Depending on what the thread is blocked by, what you request might actually not be possible. There are instances when a thread hangs in the kernel, making it effectively impossible to terminate the process (the only way to terminate such a process is power off or hardware reset).
|
|
|
|
|
Umm I have no idea where to look to find out how to make my MFC program run in the system tray, can someone please point me in a general direction, much appreciated
|
|
|
|
|