|
thanks.. But I wanted to know why SendMessageTimeOut( )call is timing out.. Its not timing out in Win2003,but only in Vista.
|
|
|
|
|
What does the code look like?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What functionallity should i add in following handlers to restrict user to right click in edit box........
means menu should be disable or he cant copy or paste etc
void CMyedit::OnContextMenu(CWnd* pWnd, CPoint point)
{ // TODO: Add your message handler code here
}
void CMyedit::OnCopy(WPARAM wParam,LPARAM lParam) {
// TODO: Add your message handler code here
}
void CMyedit::OnPaste(WPARAM wParam,LPARAM lParam) {
// TODO: Add your message handler code here
}
|
|
|
|
|
ani_ikram wrote: What functionallity should i add
Overiding the above functions is enough. do not call the base class functions from it...that all
|
|
|
|
|
Hi, I'm completely new to C++ as a whole, so there might be a simple answer to my question, so here goes.
I'm trying to write a program that will have the screen broken up into zones, or areas, each with a Point (location) a Size, an Image, and an array of terrain types (an enum). Trying to include a bitmap in my class made the compiler tell me that I couldn't mix managed and unmanaged types. To try to work around this, I tried extending the PictureBox control, but this has given me even more headaches.
Basically, I can't figure out how to declare/use an array in an extended control.
#pragma once
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace cli;
namespace MapEdit
{
const int MAX_TERRAIN = 3;
public ref class Zone : public System::Windows::Forms::PictureBox
{
public:
enum Terrain
{
Plain,
Hill,
Wood,
Marsh,
Stream,
River,
ShoreLine,
Impassable
};
array<byte^> ^TerrainTypes;
int TerrainTypes[3];
...
All of my errors (except the parts where I try to use these faulty enum/ array) come from this block. Frankly, I'm at a loss as to how to fix this.
Also, if someone could tell me how to include a Bitmap in an unmanged class, that would be nice too.
Thanks,
Christian
|
|
|
|
|
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.
|
|
|
|