|
Yeah, there is a greyed out section in the cpp file that has an ON_DDE macro or some such that takes as args the var and the control ID.
==============================
Nothing to say.
|
|
|
|
|
Overloaded_Name wrote: But I wanted to ask is there a better way to find out that which variables are bound to the controls (strMessage2) and which variables are not (strMessage1)?
What's wrong with consulting DoDataExchange() ? All it takes is a glance.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Yeah, this is trivial... I don't see the purpose to OP's question.
|
|
|
|
|
Well everything is OK with the existing DoDataExchange() . The number of bound variables with the controls are getting increased in my small application. I was hoping there might be a better way to look for these variables. It was just a curious question, now I know there is no such way. Thanks.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Overloaded_Name wrote: hoping there might be a better way to look for these variables
You could always ensure you give the variables meaningful names so you can easily differentiate between them.
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Overloaded_Name wrote: I was wondering if we can differenciate between two variables as they can have same type. Yet one of them can be simple class variable while other being member variable
They have the same type but different modifier (storage class): you must use the static keyword to specify class variables (see MSDN[^]).
Veni, vidi, vici.
|
|
|
|
|
I want to draw an avl tree in a dialog,the tree is done,what I don't know is how to draw it,would somebody help me?
|
|
|
|
|
|
|
Quick answer: Assign coordinates to the leaves first.
The leaves will be equally-spaced in the X direction, so assigning X coordinates can be done just by incrementing as you go through all the leaves from left to right.
The X coordinates of each interior node will be centered above its two sons.
Y coordinates are just a multiple of the level.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Many thanks.
Best wishes to you!
|
|
|
|
|
Hi,
Or another way of putting it can I do PostThreadMessage to a Worker Thread
Or if only a UI Thread has a message queue can m_pActiveWnd and m_pMainWnd
be NULL
Thanks in advance
|
|
|
|
|
To be able to send a message to a thread using PostThreadMessage , you must have a message loop in the thread using either a GetMessage or a PeekMessage .
The message queue for the thread will be created when the first message is sent to the thread.
Both UI threads and worker threads can have message queues.
|
|
|
|
|
Just to amplify Superman's answer - as soon as the worker thread makes a USER call it changes from being a worker thread to a UI thread. And it's probably better to create an invisible window in what was your worker thread to act as a target for your inter-thread messages as otherwise you'll have to add special purpose code to handle messages with NULL window handles.
|
|
|
|
|
|
See, for instance, here[^].
Veni, vidi, vici.
|
|
|
|
|
|
Thanks
Here is now my code works I have created
a CDialog * in a CDialog
<pre lange='cs'>
void Cprogdialog::Process() // <== Modal Dialog
{
class CMainFrame;
UpdateData(TRUE); // read infoe
CFileDialog dlg(TRUE, _T("asm"), _T("*.asm"), OFN_ALLOWMULTISELECT);
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
dlg.m_ofn.lpstrFilter = "*.asm,*.cbl,*.c";
dlg.m_ofn.lpstrInitialDir = "F:\\";
dlg.m_ofn.lpstrTitle = "Program Source Code";
if (dlg.DoModal() == IDOK)
AfxMessageBox("Waiting for program " +progname + "
InJobName " jobname,MB_OK);
CprogDebug *myprog; // instantiate a Debug Class <=== Modless Diloaf
</pre>
I then Create a thread in Which I have a Derived CAsynsocket Class
<b> Creating the Thread </b>
<pre lang='cs'>
myprog->progsocket = (SockCLeintThread *) AfxBeginThread
(RUNTIME_CLASSSockCLeintThread),
THREAD_PRIORITY_NORMAL,
0,CREATE_SUSPENDED);
</pre>
<b> The CWinThread Class itself </b>
<pre lang='cs'>
class SockCLeintThread : public CWinThread
{
public:
DECLARE_DYNCREATE(SockCLeintThread)
// DECLARE_DYNAMIC(SockCLeintThread)
// IMPLEMENT_DYNAMIC(SockCLientThread)
public:
CWnd *sendwindow;
CWnd *call_wnd;
CString buffer;
char thread_id[15];;
SockClient *thisocket; // <=== derived CAsynsocket
virtual BOOL InitInstance(); // Just for starters
// virtual int Run(); // keep on moving
// virtual int ExitInstance();
void receive_work(WPARAM , LPARAM);
void Sendit(WPARAM, LPARAM);
void Receiveit(WPARAM, LPARAM);
void sockoper(WPARAM, LPARAM);
LPCTSTR ipaddr;
UINT port;
BOOL idle; // looking for work
SockCLeintThread();
~SockCLeintThread();
struct {
unsigned int is_connected : 1;
} flags;
protected:
DECLARE_MESSAGE_MAP()
}
</pre>
<b> The CDialog myprog Class </b>
<pre lang='cs'>
class CprogDebug : public CDialog
{
DECLARE_DYNAMIC(CprogDebug)
public:
CString progname;
CString jobname;
CString start_addr;
CString end_addr;
CString as_id;
CString proglisting;
debugevent *debug_event_ptr;
HANDLE filemap;
HANDLE dbgmutex;
HANDLE dbgevent;
HANDLE hercprocess;
struct
{
unsigned int wait_for_prog : 1;
unsigned int prog_in_lpa : 1;
unsigned int prog_nucleus : 1;
unsigned int cics_prog : 1;
unsigned int mvs_exit : 1;
unsigned int trace_mode : 1; /* in trace mode */
unsigned int breakpt_set : 1;
unsigned int cpu_set :1;
} status;
UINT asid;
// void DoDataExchange(CDataExchange* pDX);
CProgedit *myedit;
BOOL OnInitDialog();
SockCLeintThread *progsocket; // <== CWinThread tcpip thread
DWORD Tcpipthread; // SockClientthread
CprogDebug(CWnd* pParent = NULL); // standard constructor
void receive_break_point(); // receive break point
SIZE get_line_number(char *); // get location of current break t
LRESULT break_set(WPARAM mywparam, LPARAM mylparam);
LRESULT break_point(WPARAM mywparam, LPARAM mylparam);
LRESULT receive_tcpip(WPARAM,LPARAM );
void OnRequestResize(NMHDR *,LRESULT *);
virtual ~CprogDebug();
void Build_data(char *);
// Dialog Data
enum { IDD = IDD_PROGDEBUG };
private:
char cpu[2]; // current cpu
struct {
BYTE sysmask; /* System mask (0 - 7) */
BYTE pkey; /* PSW Key (8 - 11) */
BYTE states; /* EC,M,W,P bits (12 - 15) */
BYTE asc; /* Address space control */
/* (16 - 17) */
BYTE cc; /* Condition code (18 - 19) */
BYTE progmask; /* Program mask (20 - 23) */
BYTE zerobyte; /* Zeroes (24 - 31) */
/* or (esame) (24 - 30) */
u_int /* Addressing mode (31 - 32) */
amode64:1, /* 64-bit addressing (31) */
amode:1, /* 31-bit addressing (32) */
zeroilc:1; /* 1=Zero ILC */
char zeroword[4]; /* esame only (33 - 63) */
char ia[8]; /* Instruction addrress */
/* (33 - 63) */
/* or (esame) (64 -127) */
char amask[4]; /* Address wraparound mask */
char intcode[2]; /* Interruption code */
BYTE ilc; /* Instruction length count */
BYTE unused;
} PSW;
char inst[6]; // machine code
char assem_inst[35]; // assembler mnumonic
char regs[16][16];
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL PreTranslateMessage(MSG* pMsg);
DECLARE_MESSAGE_MAP()
};
#define BUF_SIZE 300
class debugevent : public CEvent
{
private:
public:
LPVOID fileptr;
CMutex* mylock;
HANDLE filemap;
debugevent(BOOL Own, BOOL bManualReset,LPCTSTR lpszName,LPSECURITY_ATTRIBUTES lpsaAttribute);
};
</pre>
<b> I create the derived CASynSocket in the constrocter of the CWinthread Class on the heap </b>
<pre lang='cs'> SockCLeintThread::SockCLeintThread()
{
thisocket = new SockClient;
m_bAutoDelete = FALSE;
}
</pre>
accessing the the Derived CAsynsocket class in the CWinThread class I get exceptions
<pre lang='cs'>
void SockCLeintThread::Sendit(WPARAM count, LPARAM command)
{
thisocket->num_buff = count;
thisocket->AsyncSelect(FD_WRITE);
return;
}
</pre>
I set m_pMainWnd and m_pActiveWnd to (Cwnd *) myprog
<pre lang='cs'>
myprog->progsocket->m_pActiveWnd = (CWnd *) myprog;
myprog->progsocket->m_pMainWnd = (CWnd *) myprog;
</pre>
does that make it a UI interface able to get messages via PosThreadMessage
I am sure I doing something wrong as I keep on getting exceptions
Thanks
|
|
|
|
|
ForNow wrote: I am sure I doing something wrong
Well if you actually look at what you've posted you can see that none of your <pre> tags have taken, and also you have selected 'cs' as the language type instead of 'C++'.
|
|
|
|
|
Is it really that simple to change from Worker to UI
I thought you have to make the discision at design time
e.g. UI uses ::INITINSTANCE and uses the runtime class in the AFXBegeingThread
isn't a different design ??
|
|
|
|
|
Nope, as soon as you call a USER function the thread gets a message queue and woo hoo it's a UI thread. This includes things like RegisterWindow, CreateWindow...
What you're getting confused with is that MFC "worker" threads don't implement a message pump so if they call a USER function they'll get a message queue but there'll be no code (AFAIK, it's been 10 years since I did any serious MFC programming) to handle any messages that arrive.
|
|
|
|
|
|
Anything in USER.DLL, USER32.DLL - I have no idea if there's a USER64.DLL as I'm using my FreeBSD computer at the mo 
|
|
|
|
|
A lot of people let the naming convention of the threads mislead them. The difference in the two threading schemes is really more of a description of how they'll be used (although the "UI" name is not a great description since it doesn't necessarily involve dealing with a user interface).
|
|
|
|
|
No, but you can implement your own messaging system if you like.
To do this you need a message queue and a worker thread that empties it and acts on the message. Any other part of your code can lob messages onto the queue, at the head or tail depending on priority. (Message addition needs synching).
I have used this kind of design a lot in all sorts of code and it can simplify complex things massively.
==============================
Nothing to say.
|
|
|
|