|
Since this is managed c++, better ask in this[^] forum
|
|
|
|
|
Thanks, I'm so new at C++, I wasn't sure which forum to ask in.
|
|
|
|
|
i wish to draw a semi transparent object(ex:rectangle). i am managed to draw it transparent but not in semi trans. can someone help me? thanks!
transparent:
ip_dc->SelectStockObject(HOLLOW_BRUSH);
semi-trans:
?????
|
|
|
|
|
|
void UIRectangle::Draw(CDC* ip_dc, bool i_selected)
{
double x1 = m_rectangle.GetTopLeft().GetX();
double y1 = m_rectangle.GetTopLeft().GetY();
double x2 = m_rectangle.GetBottomRight().GetX();
double y2 = m_rectangle.GetBottomRight().GetY();
m_alphablend.BlendOp = AC_SRC_OVER;
m_alphablend.BlendFlags = 0;
m_alphablend.SourceConstantAlpha = 0;
m_alphablend.AlphaFormat = 0;
if(i_selected)
{
CPen pen(PS_DASH, 1, RGB(m_color_line.GetRed(), m_color_line.GetGreen(), m_color_line.GetBlue()));
CPen* old_pen = ip_dc->SelectObject(&pen);
ip_dc->Rectangle(x1, y1, x2, y2);
ip_dc->SelectObject(old_pen);
}
else
{
CPen pen(PS_SOLID, 2, RGB(m_color_line.GetRed(), m_color_line.GetGreen(), m_color_line.GetBlue()));
CPen* old_pen = ip_dc->SelectObject(&pen);
CBrush brush(RGB(m_color_fill.GetRed(), m_color_fill.GetGreen(), m_color_fill.GetBlue()));
CBrush* old_brush = ip_dc->SelectObject(&brush);
//ip_dc->SelectStockObject(HOLLOW_BRUSH);
ip_dc->Rectangle(x1, y1, x2, y2);
ip_dc->SelectObject(old_pen);
ip_dc->SelectObject(old_brush);
//ip_dc->SetBkMode(TRANSPARENT);
}
}
___________________________________________________________________________________________________
this is my code. i just add those BLENDFUNCTION m_alphablend; inside. but it seem no work. anything else i need to add into it? thanksssss!
|
|
|
|
|
Did you check the code on that link i provided.
It shows how to use AlphaBlend Function.
Here you are just initializing the parameters that needs to be passed to AlphBlend Function.
I dont see any call to AlphaBlend()..
Is it clear??
Regards,
Sandip.
|
|
|
|
|
sorry. i not see it just. i'll try my best! anyway, thanks a lot!
|
|
|
|
|
dear Sandip,
thanks so much. i can do it already~~~
|
|
|
|
|
Welcome
Regards,
Sandip.
|
|
|
|
|
hi
it is a dialog based MFC application
it has only a dialog with a web browser (activex)object
i have created it dynamicaly with CWnd wrapper class
everything ok and works well
but i want to remove sunken border of web browser object
i want it to be complete flat ,is it possible
i have tried something with class name Internet Explorer_Server
but no success
can you help me with this
also is there a way to disable contex menu of web browser object
thank you
|
|
|
|
|
Did you try removing the border style?
|
|
|
|
|
yes of course
SetWindowlong()
CWnd::ModifyStyle()
not working or i could not implement
|
|
|
|
|
Hi
1-) I compiled a DLL which is a hook dll. It calls SetWindowHookEx and hook Keyboard. and there is a hookproc.
void StartHook(HWND hWnd)
{
hHook = SetWindowsHookEx(WH_KEYBOARD, HookProc, hmod, NULL);
hWndServer = hWnd;
};
2-) And I compiled a MFC app. which includes this dll. And calls StartHook. Also it sends its handle to dll. So they can communicate each other.
HWND hWnd = ::GetDlgItem(this->m_hWnd, IDC_EDIT1);
StartHook(hWnd);
3-) In MFC app. there is an edit control which I want to show dynamically which keys user pressed.
So first i get editcontrols textlength
int textlength = SendMessage(hWndServer, WM_GETTEXTLENGTH, 0, 0) + 1 ;
and then try to replace text of the edit control with WM_SETTEXT:
TCHAR *td = new TCHAR(textlength+1);
SendMessage(hWndServer, WM_GETTEXT, textlength, (LPARAM)td);
SendMessage(hWndServer, WM_SETTEXT, 0, (LPARAM)td);
delete[] td;
4-) It doesn't work and run-time error.
Here something wrong.
In MSDN for WM_Settext's lParam parameter:
"Pointer to a null-terminated string that is the window text."
It is a pointer to another process address space and with sendmessage it is sended to another process. And it is meaningless for other process.
Is this caused run-time error?
How can i solve this problem? (I mean using WM_settext to send a string to another process)
Thanks..
modified on Tuesday, September 9, 2008 4:42 PM
|
|
|
|
|
sawerr wrote: SendMessage(hWndServer, WM_GETTEXT, textlength, (LPARAM)td);
That should be
SendMessage(hWndServer, WM_GETTEXT, textlength+1, (LPARAM)td);
sawerr wrote: 4-) It doesn't work and run-time error.
What error?
You may get better results posting a message to a window on the same
thread as the message loop the edit control is on. Let the handler
for that message do the WM_GETTEXT/WM_SETTEXT stuff instead of doing
it from the hook proc.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
OK. Understood.
But is there a way to send a text string to another application with SendMessage+WM_SETTEXT?
Because of lPararm is just a pointer, this way doesn't allow to send a buffer to another application i think. Or I couldn't find a way...
|
|
|
|
|
sawerr wrote: is there a way to send a text string to another application with SendMessage+WM_SETTEXT?
No. You could use WM_COPYDATA or some other IPC mechanism[^] however.
Did you mention another application and I missed it?
I thought this was DLL to EXE...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, it is dll to exe. But dll calls SetWindowsHookEx. So it is loaded to all processes address spaces.
So it becomes exe to exe, as in the figure:
http://www.codeproject.com/KB/DLL/hooks.aspx[^]
I thought i could update textbox's text from dll as i tried to explain above.(In dll first get text with Sendmessage-WM_gettext and append new presssed key and send it to the application with SendMessage+WM_SETTEXT)
|
|
|
|
|
sawerr wrote: So it becomes exe to exe, as in the figure:
Then I guess other options are to one of the IPC methods described
at the previous link or do something similar to what Joe does in his
article but post the WPARAM and LPARAM passed to the KeyboardProc to
a window in the exe process and let the EXE do the string stuff.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I just noticed this
sawerr wrote: int textlength = SendMessage(hWndServer, WM_GETTEXTLENGTH, 0, 0) + 1 ;
You already added 1 ... I didn't see that, but this:
sawerr wrote: TCHAR *td = new TCHAR(textlength+1);
is BAD! That should be
TCHAR *td = new TCHAR[textlength];
The wrong brackets is probably the runrime error problem, since not enough
space is allocated for a string longer than 0 TCHARs if you use parenthesis.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Shame on me. OK. I see it.
But although these stupid errors, i think wm_settext+sendmessage could not send text as i tried to explain my previous post.
|
|
|
|
|
Hi
Am new to the registry concept in C++, I need help regarding registry subkey concepts. If possible please solve my issue with example source code to get registry subkey value.
|
|
|
|
|
This article should help.
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
|
|
I'm losing my mind over some Unicode issue and hopefully someone can help me out. I haven't done a ton of MFC stuff before, so hopefully it's a simple problem.
I've Unicode enabled in this project because I've got a 3rd party library that requires it. I've subclassed CListBox to get a list box that shows multiple lines per item. I'm overriding DrawItem and MeasureItem. In DrawItem I have the following lines for drawing text:
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
...
dc.DrawText(lpszText, _tcslen(lpszText), &lpDrawItemStruct->rcItem, DT_LEFT | DT_TOP | DT_WORDBREAK);
In my main dialog class I add data to the list box like this:
m_ProductList.AddString((LPCTSTR)updates[i]->ToString().c_str());
And my text comes out looking like garbage. Usually Chinese characters. I can get the output to look correct if I do:
m_ProductList.AddString(TEXT("yoyoyoyoy\nzomgzomg\nblabla"));
I tried looking at what the TEXT macro does, but the farthest I can get is that is is an alias for L## which is difficult to google.
I've tried a lot of stuff and nothing has worked. I've tried: MultiByteToWideChar, CT2CW, A2W, and some other stuff.
My understanding of this issue is that I've got a UTF-8 encoded string from an XML file that's stored in a std::string. Then, since I'm using Unicode, DrawText is actually DrawTextW. So, I have to convert my string to Unicode, but nothing seems to be able to do that conversion.
Thanks,
Nick
|
|
|
|