|
Hi,
first of all, if you want to process these messages on the level of the list control, then don't use message reflection, because the list control is the parent of the header control.
Second, the embedded CHeaderCtrl's control id is always zero, so the filter in On_Notify has to be zero as well.
Because the wizard would generate reflecting message mapping, which is wrong here,
you have to record the message handlers by hand between the end of the message map generated by the wizard
//}}AFX_MSG_MAP
and
END_MESSAGE_MAP()
like
ON_NOTIFY(HDN_BEGINTRACKA, 0, Your_Begintrack)
ON_NOTIFY(HDN_BEGINTRACKW, 0, Your_Begintrack)
ON_NOTIFY(HDN_ENDTRACKA, 0, Your_Endtrack)
ON_NOTIFY(HDN_ENDTRACKW, 0, Your_Endtrack)
Furthermore, you have to declare the functions following
//}}AFX_VIRTUAL
in the class definition of your list control:
afx_msg void Your_Begintrack(NMHEADER *nmheader, LRESULT *pResult);
afx_msg void Your_Endtrack(NMHEADER *nmheader, LRESULT *pResult);
(you are free to decide the names of the functions).
This should suffice.
|
|
|
|
|
Thank you very much for the updated information.
It works exactly as desired now.
The class derived from CListCtrl class now gets the begin track and end track messages from the embedded header control, exactly as I had hoped
|
|
|
|
|
Is there any way to copy a vector from one class to another? I have a SDI app, and I am using a UI thread to do some complex operations, right now both the UI thread and my CMainFrame classes have the exact same vector and structure, the vector for both classes contain one structure with multiple variables.. anyway it would be really cool if I could simply copy the mainframe vector over to the UI thread vector.. Any ideas? Right now I have to loop the vector and read everything out, big pain..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hello,
You can use a pointer to the vector in on of the classes, so the both use the same one. You must make sure that you use a thread-safe version of the STL or sync access yourself using critical sections and such.
The other thing you can do is:
<br />
copy(source.begin(), source.end(), dest.begin());<br />
Hope this helps...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Heck it's even easier!
dest= source;
Assuming of course you're protecting this with a mutex/critical section etc.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Am new to C++ and don't know if I'm doing something fundementally wrong. Have a form with a textbox and buttons. When I click on button, I am running a function in my .cpp file. However, in this function I need to update the text box in the form. Have created a public function set_address in the .h file form1 class definition that uses the following code.
public:
void Form1::set_address(char *add)
{
char temp_str[80];
sprintf(temp_str,add);
textBox1->AppendText(temp_str);
}
When I call it from my .cpp file with
Form1* pFm = new Form1;
pFm->set_address(temp_str);
It compiles OK and even runs the code, but the text box is not updated. If however I call the function from a clickbutton
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{
char temp_str[80];
sprintf(temp_str,"from button");
set_address(temp_str);
}
It happily updates the text box.
Have been pulling my hair out for 2 days, so any help would be GREATLY appreciated
Thanks
Dave C
|
|
|
|
|
If you are already inside the form1 instead of doing a Form1* pFm = new Form1 etc... just simply call set_address(temp_str);
You should not have to create a new Form1 object..
Another thing.. If you are not in CForm1 lets say you are calling this from CMainFrame you would probably want to do something like this...
CForm1* pForm = (CForm1*)AfxGetActiveView();
ASSERT(pForm);
pForm->set_address(temp_str);
Anyway you get the idea..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I am calling from outside the form, this is part of the problem, set_address is not recognised otherwise. When I tried your changes it didn't like ASSERT or AfxGetActiveView. Can't even find AfxGetActiveView on the msdn microsoft website. I am assuming that calling the form as a new form is what's causing my problem, but this is the only way I can get it to compile. Any other ideas?
Using Microsoft Visual C++.net Version 2003
Dave C
|
|
|
|
|
What class are you trying to call that function from? Is your app it a SDI or MDI? If it's a MDI are you trying to call the from another view?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
V5dave wrote:
When I tried your changes it didn't like ASSERT or AfxGetActiveView
My bad it's GetActiveView() instead of AfxGetActiveView.. didn't check the syntax, was just typing on the fly.. ASSERT should work fine, it's for debugging, if the view doesn't exist it will assert.. anyway for testing you can remove that line..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Got the ASSERT to work, needed DEBUG::ASSERT, but doesn't like GetActiveView, says identifier not found. Am calling from a normal function
void Test01(void)
{
// Call is in here
}
The form I'm calling is
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
public:
void Form1::set_address(char *add)
{
char temp_str[80];
sprintf(temp_str,add);
textBox1->AppendText(temp_str);
}
//Loads of other standard definition and click button stuff
}
Is this a problem of calling managed types from unmanged types?
Its an SDI only.
Dave C
|
|
|
|
|
Hello all,
I am working on an editor that automatically applies some formatting as the user types. Among these operations are syntax highlighting and character string insertions. I am currently using the ITextRange interface to apply syntax highlighting since it has been suggested elsewhere that this is the key to maintaining undo/redo ability in this context. Unfortunately I am not having any luck preserving the undo buffer in any useful state! Does anyone have any experience with this? Is it a matter of grouping operations with the (TextDoc) Begin/EndEditCollection functions? So far they have not yielded their secrets to me either
Any advice would be greatly appreciated!
Thanks,
Jon
|
|
|
|
|
Hi I'm having a lot of problems with mouse events. In an MDI application I have a CDialogBar derived class which needs to keep track of mouse movements in the parent frame. Using the ClassWizard I've added the necessary functions but they don't work. Within the CDialogBar derived class there's a CEdit object. Within the WM_NCMOUSEMOVE event handler the CEdit object has it's window text set to the mouse position. Well nothing happens. The application runs, but for whatever reason the dialog bar doesn't get the non-client mouse move event. I've added handlers for WM_NCLBUTTONDOWN and WM_NCLBUTTONUP but nothing happens.
Can anyone tell me what's going on? How do I make my CDialogBar derived class capture mouse events in the parent frame?
|
|
|
|
|
Have you tried to handle these events in CMainFrame and then let CMainFrame call a user defined function in your derived CDialogBar class?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I just tried that, and it doesn't work. The code compiles, and application runs but the CFrameWnd derived class still doesn't get any mouse events. I also tried OnNcMouseMove(UINT nHitTest, CPoint point) in the dialog bar, but no dice.
I'm at a total loss...there must be something I'm missing. I can email you the project, maybe you can figure it out.
|
|
|
|
|
I would try to handle the WM_MOUSEMOVE event with in CMainFrame or CFrameWnd (SDI or MDI) what ever the case maybe.. You can even try to do TRACE("Mouse Moving\n"); With in a bunch of functions in the MainFrame or ChildFrame classes to see what window is receiving the messages you are looking for.. here is a example of handling the WM_MOUSEMOVE with in CMainFrame class.. note this is by hand, I havent compiled it.
void CMainFrame::OnMouseMove(UINT nFlags, CPoint point)
{
CFrameWnd::OnMouseMove(nFlags, point);
}
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I just downloaded the zip and made the adjustments.. I just emailed the project back to you.. Just incase here is the code...
LRESULT CChildView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_MOUSEMOVE)
{
CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
ASSERT(pMain);
TRACE("Mouse Movement\n");
CPoint point = (CPoint)lParam;
CString str;
str.Format("OnMouseMove at (%d,%d)",point.x,point.y);
pMain->SetMessageText(_T(str));
}
return CWnd ::WindowProc(message, wParam, lParam);
}
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I have an application with two panes - a tree view in the left pane and a set of property pages in the right. I can put any value into an edit control from the program but I can't type any entries in from the keyboard. The only key that seems to work is the 'Delete' key in the numeric keypad. The edit control is not read only. I've tried making the edit control a CString, an int and a CEDIT and the result is always the same.
If I put exactly the same code and dialog in a popup dialog instead of a property page it works perfectly
Anybody got any ideas??
Tim
|
|
|
|
|
Just a guess...but maybe it has something to do with the property page capturing the keystroke messages and not passing them onto the edit controls???
Sounds like something that may be in the C++ FAQ...might wanna check it out
Cheers...
How do I print my voice mail?
|
|
|
|
|
Hi,
Please forgive me any redundancy or newbie naivete, but i am having a problem with setting text in a static field in a dialog with the full pathname retrieved by a call to GetPathName() member of the CfileDialog class. Specifically, a path such as:
D:\Program Files\Microsoft Visual Studio\MyProjects\CmodConverter\Debug. It gets truncated to:
D:\Program Files\Microsoft Visual.
I presume this is due to a long-filename issue since d:\celestia\models\cassini.3ds works fine.
Any ideas?
Thanks,
Sean
Firefly, Stargate, Farscape: in that order
|
|
|
|
|
It sounds like you need to make the static control wider.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hmmm,
It seemed big enough but i did not check it with that big a string - i will experiment further. Also, I was wondering about the backslashes in the path - could an escape sequence be happening? I will fiddle with that notion too...
Thanks for the reply!
Sean
Firefly, Stargate, Farscape: in that order
|
|
|
|
|
smbika wrote:
Also, I was wondering about the backslashes in the path - could an escape sequence be happening?
No, that only applies to string literals in the code.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks again for the help - it was indeed the size of the field, but i did find i had to change the slashes to double slashes or they did not show up - sigh...
I have another problem which i will begn another thread on...
lemme know...
Firefly, Stargate, Farscape: in that order
|
|
|
|
|
darn it - looks like i was wrong about the double slashes too - sokay - as long as it works and i have learned
thanks again and my apologies for the mistake...
Sean
Firefly, Stargate, Farscape: in that order
|
|
|
|