|
Hello,
Here's the problem:
I have an ActiveX control and I want to change - more exactly cancel - the way it handles some basic input window events in a MFC application. (It doesn't export the events of course)
I've tried the "classic" SetWindowLong way for Win32 API subclassing but it doesn't seem to work and I didn't really expected (or maybe I'm not using it right.. I don't know..)
I have the ActiveX Control placed in a dialog. The class instance variable for the Control is a member variable of the dialog class.
In OnInitDialog I have the next lines of code:
CWnd * wnd_ctrlax = GetDlgItem(IDC_PLUGIN1);<br />
HWND handle_ctrlax = wnd_ctrlax->GetSafeHwnd();<br />
old_wnd_proc = (WNDPROC)SetWindowLong(handle_ctrlax, GWL_WNDPROC, (LONG)Subclassing);
old_wnd_proc and Subclassing are both declared global. (Maybe here I'm doing something wrong...)
The new WndProc looks something like this:
LRESULT APIENTRY Subclassing (HWND hWnd, <br />
WORD Message, <br />
WORD wParam, <br />
LONG lParam)<br />
{<br />
<br />
if (Message == WM_LBUTTONDBLCLK)<br />
{<br />
return 0;<br />
}<br />
<br />
if (Message == WM_LBUTTONDOWN)<br />
{<br />
return 0;<br />
}<br />
<br />
return CallWindowProc(old_wnd_proc, hWnd, Message, wParam, lParam);<br />
}
I've put breakpoints in the new WndProc handles for the mouse click messages. Of course they never get trigerred.. but the WndProc is entered = a breakpoint on the return CallWindowProc line is triggered continuously.
It just doesn't catch my mouse input in the control = the old functionality remains the same.
If somebody had the some problem or knows an answer for subclassing an ActiveX control and can give me a hint I'll really apreciate it.
-- modified at 8:37 Monday 4th June, 2007
|
|
|
|
|
dkmr wrote: CWnd * wnd_ctrlax = GetDlgItem(IDC_PLUGIN1);
When you insert an Activex to your dialog, two windows are created. In your case the first one is the IDC_PLUGIN1. The other window is created as the child of IDC_PLUGIN1. This widnow is the actaull activex you see. So get the child window of IDC_PLUGIN1 and try subclassing it.
|
|
|
|
|
my application runs in two modes.”online” mode and “offline” mode.by default,application will be in offline mode.when clicking online button in the tool bar,mode will change to offline.what i want is an indication system.when application is in online,an icon should come indicating "ONLINE" untill mode changes to OFFLINE.and vice vorsa.i 'm using MFC.using toolbar,or dialoge bar ,what s the code to create this?same button in the toolbar is using to swiching between two modes.for first click" online " button should come and on second click "offline".try it out.
|
|
|
|
|
You could either put the indicator in the toolbar, or at the bottom in the status line (i.e., similar to the CAPS and NUM indicators).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i think its better to use a dialog bar
Proud To Be an Indian
|
|
|
|
|
vivekphlp wrote: i think its better...
I was merely giving options, not opinions.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ok sorry
Proud To Be an Indian
|
|
|
|
|
Hi everone,
I'm developing an Internet Explorer add-on,which will put an extra image on the document's specified location.Everything works fine,but Internet Explorer won't display the image if it is located in the local system (the user's computer,i mean).Since I'm sure the image url (formed as 'file://c:/folder/image.gif ') is correct and IE displays images on the internet,I think it's a kind of security feature of IE.
Does anyone have any idea on how I can put a local image on the document without asking the user to alter security settings?
|
|
|
|
|
I have created an SDI application. There i have created 3 dockable toolbars without using Rebars. The problem is that all toolbars appears in a separate line. I want them to be on after the another. How to do this.
Please help me.
Anurag Gandhi.
|
|
|
|
|
Hi,
Could you please specify the styles CBRS_* used while creating and docking it.
Best Regards
Raj
|
|
|
|
|
Following is the complete functiom:
Similar is the function for other two toolbars also.
bool CMainFrame::AddMarginToolbar()<br />
{<br />
if (!m_MarginToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP<br />
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||<br />
!m_MarginToolBar.LoadToolBar(IDR_MARGIN))<br />
{<br />
TRACE0("Failed to create Case toolbar\n");<br />
return false;
}<br />
m_MarginToolBar.SetWindowTextW(_T("Margin"));<br />
<br />
m_MarginToolBar.EnableDocking(CBRS_ALIGN_ANY);<br />
EnableDocking(CBRS_ALIGN_ANY);<br />
DockControlBar(&m_MarginToolBar);<br />
return true;<br />
}
I want that next toolbar should appear automatically previous first toolbar.
Thanks a lot in advance.
Anurag Gandhi.
|
|
|
|
|
Hi,
You need some thing more to get this, you need to use the full parameters of
DockControlBar();
for instance if you want to set the toolbar before the first tool bar aligned on top
you can do this,
DockControlBar(&m_MarginToolBar);
RecalcLayout();
CRect rect;<br />
m_MarginToolBar.GetWindowRect(&rect);<br />
rect.OffsetRect(1,0);
<br />
<br />
DockControlBar(&m_wndToolBarSecond, AFX_IDW_DOCKBAR_TOP, rect );
think and modify alignment according to your requirement.
Best Regards
Raj
-- modified at 9:54 Monday 4th June, 2007
|
|
|
|
|
Thanks a lot Raj.
I have implemented it and it is working fine.
Anurag Gandhi.
|
|
|
|
|
Hi. Ok slightly long explaination, I apologise!
I am currently developing a 3d drawing system and am having a few problems with storing the vertexes of each line.
Basically there are two objects that I am using to construct a drawing: points and lines. A point stores the x y z coordinate of a vertex. Each point that is drawn is stored in a global vector of points. A line consists of many points and consists of a vector that stores a reference to each pointer in the global vector.
The problem I am having is that the vector of pointers in the line object start off pointing to the vertex in the global array but when another point is added to the global array it can no longer find it instead it comes back with the vertex being at some strange position, the most common coordinate being -1.5883997e38. I can see it may be something to do with how the global vector stores the point objects.
Ive checked:
The actual values of the pointers in the line vector do not change value
The global vector containing the points stores the points ok
Is this explanation enough or do I need to post code?
Kevin
|
|
|
|
|
Me think your design suck; I don't think it's efficient (or doable) to keep reference to vector items.
create a struct/class for your coordinate.
make an base class called Geometry (or whatever you like), make a class Point, make a class Line both derived from the base class Geometry.
Create a vector of pointer to Geometry.
something like :
struct Coordinate { double x, y, z;};
class Geometry
{
void Draw()=0;
};
class Point : public Geometry
{
Coordinate m_Coordinate;
void Draw(){};
};
class Line : public Geometry
{
Coordinate m_Start, m_End;
void Draw();
};
std::vector < Geometry* > m_GeometryVector;
|
|
|
|
|
kevinbrydon wrote: Is this explanation enough or do I need to post code?
Maybe posting the relevant code will help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi,
First of all your approach of using STL classes for 3D drawing system is not so good.
3D graphics being a expensive operation on computer, experts are using hardware accelerated methods like using graphics library like DirectX, openGL.
stl::Vector is an expensive array is inefficient for such application.
Then, what do you mean by reference, reference to vector item.
please post some code snippet.
|
|
|
|
|
Ok thanks for replying
Max:
Thats basically the design I have but without the geometry class. I am never going to be able to draw a point, it is simply used to construct a line (the system is only going to be able to draw lines)
Pallini, Rajkumar:
Heres some code:
---------------------------------
// holds all the lines
std::vector <line> lines;
// holds all the points
std::vector <point> allpoints;
struct Point
{
public:
GLfloat x, y, z;
bool selected;
/* constructors */
Point()
{
}
Point(const GLfloat & xval, const GLfloat & yval, const GLfloat & zval)
{
}
Point(const Point & from)
{
}
};
/* a class to describe a line in 3 dimensional space */
class Line
{
public:
// each pointer in this vector should point to a Point object in allpoints
std::vector <point*> points;
bool selected;
// Initializes variables
Line()
{
}
Line(int typein)
{
}
// Functions
void addPoint(Point & p)
{
points.push_back(&p);
}
void draw() // ive only included part of it
{
Point current;
glLineWidth(thickness);
glColor3fv(color);
glBegin(GL_LINE_STRIP);
for (int i = 0; i < points.size(); i++)
{
current = *(points[i]);
glVertex3f(current.x, current.y, current.z);
}
glEnd();
}
};
-----------------------------
the reason for storing all the points in one big data structure and then referencing them makes it easier to select the lines and points later on. the "allpoints" in the final implementation is really a vector
std::vector <point> sector[GRID_SIZE][5][GRID_SIZE];
when a point is created it is assigned to a sector based on its x, y, z coordinates (forget about that for now)
when a point is selected i want it to flag "selected = true" by changing its value through the allpoints vector. then when the line is drawn it checks the value of each of its points to see if any has been selected (this is why i use pointers so it checks the actual point and not a copy of it), if so it will change to a different colour.
Rajkumar:
I am using opengl with sdl and im not all that bothered about how fast the system runs as its only really a proof of concept. when i wasnt using pointers the system ran fast (but not using pointers meant that things couldnt be selected)
thanks
kevin
|
|
|
|
|
This approach won't work if you store the addresses of pointers which are in an STL structure rather than indexes into the structure. STL moves the pointers around when you add stuff because it tends to store stuff in red/black balanced trees internally. As soon as it moves things around to keep its trees balanced your pointers to pointers become pointers to garbage. In other words you have to treat STL containers as black boxes and not make assumptions about how they store stuff. Once you put something in a std::vector or std::map the std::vector or std::map owns it and can do what it wants.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
ah right, thanks very much. would it be sensible to create my own data structure then?
|
|
|
|
|
I would Most people will advise you to use the stl constainers because they are fast and reliable. I think for an experimental app like this you'd learn more by creating your own data structures. It's not as hard as you'd think.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
|
I cannot understand completely you code (maybe some <pre> TAGs probably will help),
however IMHO you may have some troubles if memory reallocation happens (and it can happen) in the global vector, beacause the pointers stored in your Line class loose sense.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
yeh i think its a memory reallocation issue. im new to this whole pointers thing, ill get it eventually!
|
|
|
|
|
Rajkumar_R wrote: First of all your approach of using STL classes for 3D drawing system is not so good.
STL is not a graphic API, but we still need to keep our data somewhere before sending it to OpenGL or DirectX.
|
|
|
|