|
Thank you very much for the quick response! These are the values that I have for my DDV & DDX
DDV_MinMaxFloat(pDX, m_dradix, 0.f, 1000.f);
DDX_Text(pDX, IDC_EDITX, m_editx);
DDV_MinMaxFloat(pDX, m_editx, 0.f, 1.f);
DDX_Text(pDX, IDC_EDITY, m_edity);
DDV_MinMaxFloat(pDX, m_edity, 0.f, 1.f);
DDX_Text(pDX, IDC_EDITL, m_editl);
I checked out the assertion and it points me to this:
void CLayerDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
switch(pScrollBar->GetDlgCtrlID() ){
case IDC_SLIDERL:
if (m_sliderl == nPos)
break;
UpdateData(CTRL2VAR);
if (m_sliderl < SLIDERLMIN)
m_sliderl = SLIDERLMIN;
m_editl = (float)m_sliderl*5.0;
UpdateData(VAR2CTRL);
break;
case IDC_SLIDERX:
if (m_sliderx == nPos)
break;
UpdateData(CTRL2VAR);
****** m_editx = (float)m_sliderx/100.0;
UpdateData(VAR2CTRL);
break;
case IDC_SLIDERY:
if (m_slidery == nPos)
break;
UpdateData(CTRL2VAR);
****** m_edity = (float)m_slidery/100.0;
UpdateData(VAR2CTRL);
break;
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
At the point where I put the stars is where the assertion points me to. I think that my problem is the variable "m_dradix" from above as the values of m_editx and m_edity into a function that uses this variable. Is there are way I can track this variable through out the whole process to see what happens to it's value, I cannot figure out how to do it in 2k5?
Thanks again
Simon
|
|
|
|
|
Using UpdateData() with data validators isn't going to work unless you ensure the controls
and their corresponding data member variables contain valid values.
It may be best to update the relevent controls directly during a slider scroll instead of
relying on DDX to do it.
An explanation of some pifalls with UpdateData can be found in this essay:
Joseph Newcomer: Avoiding UpdateData[^]
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'm sure that it is not the UpdateData that is causing the problem, something has changed in that way it is handling the math, does anyone know of a page that talks about how the math functions have changed from 2003 to 2005?
Thanks
|
|
|
|
|
simoncoul wrote: I'm sure that it is not the UpdateData that is causing the problem
OK but you said the message box was looking for a number between 0 and 1000.
You showed a validator on m_dradix - DDV_MinMaxFloat(pDX, m_dradix, 0.f, 1000.f);
What is the value of m_dradix at the time of the scroll message?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thank you very much everyone I have found my problem. I piece of the code was passing a zero into a log base 10, resulting is crazy numbers. I just don't understand why VC6 and VS2003 did not pick this up as an error?
|
|
|
|
|
Hi folks,
Got a Q re updating text on a status bar after changing focus from an application. I have a program I wrote that updates a database and shows the numbers of records processed on the status bar. When I change focus from that program the counter stops and when I subsequently go back to it, the numbers of recds processes stay frozen. What can I do to update the status bar once the program regains focus? Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
are you using MFC and UpdateCmd mechanism?
led mike
|
|
|
|
|
Using MFC and in CMainFrame() I have the following code. That's all I have for code handling the status bar.
void CMainFrame::UpdateStatus(UINT nPane, CString str) {
this->m_wndStatusBar.SetPaneText(nPane, str);
}
ralf.riedel@usm.edu
|
|
|
|
|
You should do some reading about the MFC macro ON_UPDATE_COMMAND_UI and associated framework implementation.
led mike
|
|
|
|
|
hi i have to change the dialog background color at runtime frequently. how to do this
|
|
|
|
|
* Handle WM_CTLCOLOR (handler OnCtlColor)
* prepare a HBRUSH (CreateSoldBrush or so)
* return that brush from the handler (also use CDC::SetBkMode(TRANSPARENT) if needed)
--
=====
Arman
|
|
|
|
|
prathuraj wrote: change the dialog background color at runtime
On the WM_CTLCOLOR you need when want to use SetBkColor(); use of a global variable(COLORREF).
|
|
|
|
|
I currently get a C++ compiler error 32385:
Ambiguous access of CreateNewThread in 'mainloop'
Now, The cause of this is because the mainloop class inherits,
ClxThread object, and Poll_LenzeInvertors object. The Poll_LenzesInvertors objects also inherits ClxThread object. The ClxThread object has a function called CreateNewThread() that spinns a thread of virtual function called ThreadFunc(). I used the ClxThread to create OO way to create threads. Howver, this seems to be the problem with multiple inheritenace.
I would like to find a solution to this problem and still be capable of using my ClxThread Object. Any advise would be helpful.
Is there a way to distrigish which base class you are trying to call?
Should i just rewrite ClxThread so, it does not have to be inherited to work...
Scott
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
ScotDolan wrote: I currently get a C++ compiler error 32385:
C2385 perhaps?
"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
|
|
|
|
|
yes, My mistake on the error number.
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
Try overloading CreateNewThread() in your derived class. There you can now call ClxThread::CreateNewThread() or Poll_LenzesInvertors::CreateNewThread() - whatever your logic requires.
Failure is not an option - it's built right in.
|
|
|
|
|
I'm not sure to have fully understood your description (a small drawing or scheme would be usefull here). Is the case described here[^] the problem ?
Try to make the inheritance virtual:
class MyClass : public virtual CMyBase
But in general, this kind of situation should be avoided if possible.
|
|
|
|
|
Cedria,
The dread problem is exactly what i am seeing and the solution you provide works. That web site was helpful also.
Scott
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
thank you.
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
Cédric,
I miss spoken, the virtual keyword did make the code compile but it still did not function as as expected.
I want to achieve the following functionality of having two ClxThread base objects using inheritence. I basiclly develop a ClxThread class object that provides all the functionaliy to create, kill, suspend, and start a Thread function. I now realize my design decision of making clxthread as base class was probably not the best idea. However, it does make it easy to turn any class into a little worker class/app. Is thare any way i can achieve my desire results.
Desire Results Actual Results
ClxThread ClxThread
\ / \
\ / \
\ / \
Poll ClxThread Poll |
\ / \ /
\ / \ /
\ / \ /
mainloop mailoop
Here is the header for the clx thread class
<br />
<br />
class ClxThread<br />
{<br />
public:<br />
ClxThread();<br />
virtual ~ClxThread();<br />
<br />
typedef unsigned (__stdcall *PTHREADFUNC)(void *);<br />
bool CreateNewThread(void);<br />
bool CreateNewThread(PTHREADFUNC pThreadFunc);<br />
bool Wait();
bool Suspend();
bool Resume();
bool Kill();
bool IsActive();
<br />
virtual void ThreadEntry(){ }<br />
virtual void ThreadExit(){ }<br />
virtual void ThreadRun(){ }<br />
<br />
static UINT WINAPI _ThreadFunc(LPVOID pParam);<br />
<br />
public:<br />
HANDLE m_hThread;
UINT uiThreadId;
<br />
bool m_bActive;
DWORD m_lpId;
};
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
Why do you want to do such a thing ? I really don't understand why you want to inherit from ClxThread once again.
You know that the functionalities of your class will be inherited even if there is a class (Poll) in between ?
|
|
|
|
|
I want to inherit ClxThread twice because, i need to create two ClxThreads which are just worker threads. One in the Mainloop and one in Poll. It is looking like I should change ClxThread to have the capablities to be object within Mainloop and Poll instead of a inherited object.
<br />
class ClxThread<br />
{<br />
public:<br />
ClxThread();<br />
virtual ~ClxThread();<br />
<br />
typedef unsigned (__stdcall *PTHREADFUNC)(void *);<br />
bool CreateNewThread(void);<br />
bool CreateNewThread(PTHREADFUNC pThreadFunc);<br />
bool Wait();
bool Suspend();
bool Resume();
bool Kill();
bool IsActive();
<br />
virtual void ThreadEntry(){ }<br />
virtual void ThreadExit(){ }<br />
virtual void ThreadRun(){ }<br />
<br />
static UINT WINAPI _ThreadFunc(LPVOID pParam);<br />
<br />
public:<br />
HANDLE m_hThread;
UINT uiThreadId;
<br />
bool m_bActive;
DWORD m_lpId;
};<br />
The main loop classes header.
<br />
<br />
class mainloop : public LENZE_8200_MOTION, private ClxThread<br />
{<br />
public:<br />
mainloop();<br />
~mainloop();<br />
<br />
void Start(void){ CreateNewThread( ); };
<br />
protected: <br />
<br />
void init_mc362X(void);<br />
bool read_mc362x(void);<br />
bool read_lenze_cfg_sheet(void);<br />
bool read_independencer( void );<br />
<br />
private: <br />
void ThreadRun(void); <br />
<br />
MC362X_MOTION isacard;
<br />
ClxUdp cmd_socket;
ClxUdp data_socket;
<br />
bool isRaising;<br />
void Raise(void);<br />
bool Balance_A( double position );<br />
void Balance_B(void);<br />
void init_lift(void);<br />
void lift(void);<br />
<br />
private:<br />
bool m_bBalanced;<br />
char m_cStateCurrent;<br />
char m_cStateLast;<br />
bool m_bDown;<br />
bool m_bEStop;<br />
bool m_bPortUp;<br />
bool m_bStarboard;<br />
bool m_bCanopyOpen;<br />
bool m_bUp;<br />
char m_cCommand; <br />
<br />
};<br />
The Poll classer headers
<br />
class LENZE_8200_MOTION : public ClxThread, protected CLX_LENZE_8200<br />
{<br />
public:<br />
LENZE_8200_MOTION(void);<br />
~LENZE_8200_MOTION(void);<br />
<br />
public:<br />
bool init_lenze8200( int comm_port, int baud_rate, long timeout_ms, int maxtxfailures );<br />
bool start_lenze8200(void){ return CreateNewThread(); }<br />
<br />
void pitch_set_address( char address ){ return SetAddress( &pitch_axis_data, address ); };<br />
char pitch_get_address( void ){ return GetAddress( &pitch_axis_data ); }<br />
<br />
}<br />
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
My 2 cents...
From the sound of the class names involved -
If you think in terms of "is a..." and "has a..." where "is a..." means you derive from and "has
a..." means you have a member object, it sounds like Poll_LenzeInvertors doesn't need to BE a
thread object but needs to HAVE a thread object.
The same with mainloop - is mainloop a poll object, or does it need to have a poll object.
Maybe something to think about in the design. If not, simply ignore
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark,
I think you are right, I am thinking I need stop inheriting a ClxThread and declare a clxthread object within the mainloop and poll_lenze class. However, I have been struggling to pass a void ThreadFunc(void) into CreateNewThread(PTHREADFUNC pThreadFunc); which turns the function ThreadFunc into working thread/function. However, if i create a function in mainloop like this static UINT WINAPI MaintainingThreadProc(LPVOID pParam); and pass it into CreateNewThread(PTHREADFUNC pThreadFunc) Than, MaintainingThreadProc() function becomes a worker thread. I really would like to just pass the stardard void ThreadFunc(void) function prototype if possible.
class ClxThread<br />
{<br />
public:<br />
ClxThread();<br />
virtual ~ClxThread();<br />
<br />
typedef unsigned (__stdcall *PTHREADFUNC)(void *);<br />
bool CreateNewThread(void);<br />
bool CreateNewThread(PTHREADFUNC pThreadFunc);<br />
bool Wait();
bool Suspend();
bool Resume();
bool Kill();
bool IsActive();
<br />
virtual void ThreadEntry(){ }<br />
virtual void ThreadExit(){ }<br />
virtual void ThreadRun(){ }<br />
<br />
static UINT WINAPI _ThreadFunc(LPVOID pParam);<br />
<br />
public:<br />
HANDLE m_hThread;
UINT uiThreadId;
<br />
bool m_bActive;
DWORD m_lpId;
};<br />
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
ScotDolan wrote: I am thinking I need stop inheriting a ClxThread and declare a clxthread object within the mainloop and poll_lenze class.
Maybe Whatever is best for your design. I suppose since mainloop and poll_lenze both have
associated threads, they could each derive from ClxThread, but mainloop, then, shouldn't be
derived from poll_lenze since mainloop is not a poll_lenze.
ScotDolan wrote: if i create a function in mainloop like this static UINT WINAPI MaintainingThreadProc(LPVOID pParam); and pass it into CreateNewThread(PTHREADFUNC pThreadFunc)
I'm not sure how you've implemented your ClxThread class, but from the header info,
CreateNewThread(PTHREADFUNC pThreadFunc) needs as a parameter a pointer to a function declared as
unsigned __stdcall func(void *). You shouldn't be able to pass a pointer to a function declared
as UINT WINAPI MaintainingThreadProc(LPVOID pParam).
Since you've put a nice little wrapper around a thread, I'm not sure why you need to pass a
thread proc in...
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|