Click here to Skip to main content
15,899,126 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: draw an AVL tree Pin
houalfred5-Jun-12 0:47
houalfred5-Jun-12 0:47 
QuestionDoes Worker Thread Have a Message Queue Pin
ForNow2-Jun-12 17:01
ForNow2-Jun-12 17:01 
AnswerRe: Does Worker Thread Have a Message Queue Pin
«_Superman_»2-Jun-12 17:19
professional«_Superman_»2-Jun-12 17:19 
AnswerRe: Does Worker Thread Have a Message Queue Pin
Aescleal2-Jun-12 20:34
Aescleal2-Jun-12 20:34 
GeneralRe: Does Worker Thread Have a Message Queue Pin
ForNow3-Jun-12 6:33
ForNow3-Jun-12 6:33 
GeneralRe: Does Worker Thread Have a Message Queue Pin
CPallini3-Jun-12 7:38
mveCPallini3-Jun-12 7:38 
GeneralRe: Does Worker Thread Have a Message Queue Pin
Luc Pattyn3-Jun-12 9:06
sitebuilderLuc Pattyn3-Jun-12 9:06 
GeneralRe: Does Worker Thread Have a Message Queue Pin
ForNow3-Jun-12 9:58
ForNow3-Jun-12 9:58 
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
GeneralRe: Does Worker Thread Have a Message Queue Pin
Richard MacCutchan3-Jun-12 22:05
mveRichard MacCutchan3-Jun-12 22:05 
GeneralRe: Does Worker Thread Have a Message Queue Pin
ForNow3-Jun-12 6:39
ForNow3-Jun-12 6:39 
GeneralRe: Does Worker Thread Have a Message Queue Pin
Aescleal3-Jun-12 9:17
Aescleal3-Jun-12 9:17 
GeneralRe: Does Worker Thread Have a Message Queue Pin
ForNow3-Jun-12 10:01
ForNow3-Jun-12 10:01 
GeneralRe: Does Worker Thread Have a Message Queue Pin
Aescleal4-Jun-12 0:08
Aescleal4-Jun-12 0:08 
GeneralRe: Does Worker Thread Have a Message Queue Pin
Albert Holguin4-Jun-12 8:07
professionalAlbert Holguin4-Jun-12 8:07 
AnswerRe: Does Worker Thread Have a Message Queue Pin
Erudite_Eric2-Jun-12 21:13
Erudite_Eric2-Jun-12 21:13 
GeneralRe: Does Worker Thread Have a Message Queue Pin
Albert Holguin4-Jun-12 8:09
professionalAlbert Holguin4-Jun-12 8:09 
Questionhow to right vector of pointers to binary file ? Pin
Asaf Shay2-Jun-12 10:02
Asaf Shay2-Jun-12 10:02 
AnswerRe: how to right vector of pointers to binary file ? Pin
Chris Losinger2-Jun-12 17:22
professionalChris Losinger2-Jun-12 17:22 
AnswerRe: how to right vector of pointers to binary file ? Pin
«_Superman_»2-Jun-12 17:29
professional«_Superman_»2-Jun-12 17:29 
GeneralRe: how to right vector of pointers to binary file ? Pin
Asaf Shay3-Jun-12 6:39
Asaf Shay3-Jun-12 6:39 
GeneralRe: how to right vector of pointers to binary file ? Pin
«_Superman_»3-Jun-12 15:19
professional«_Superman_»3-Jun-12 15:19 
QuestionHow to get static splitter right pane dimensions - size? Pin
Vaclav_1-Jun-12 9:56
Vaclav_1-Jun-12 9:56 
AnswerRe: How to get static splitter right pane dimensions - size? Pin
«_Superman_»1-Jun-12 17:59
professional«_Superman_»1-Jun-12 17:59 
QuestionCopying vector of pointers to another vector Pin
a1_shay1-Jun-12 6:58
a1_shay1-Jun-12 6:58 
QuestionRe: Copying vector of pointers to another vector Pin
Code-o-mat1-Jun-12 10:58
Code-o-mat1-Jun-12 10:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.