|
|
As to multi-threaded programming knowledge I still know very little
Do you know How I want to master this skill
But I have not find any material.
Would you like to introduce some good articles available for me?
Thank you in advance!
|
|
|
|
|
|
Here are some:
http://www.flounder.com/callbacks.htm
http://www.flounder.com/uithreads.htm
http://www.flounder.com/workerthreads.htm
|
|
|
|
|
|
some device continues to send datas (UDP) to one port of
my computer ,now i needs to get the datas and send it out.
how can i do it .what functions shall i use ??
THANKS A LOT !
a good man
|
|
|
|
|
|
I need to remember the values of variables that were assigned in one dialog box after that dialog box creates another dialog box. Because I don't want to use global variables I have resorted to using hidden controls on the first dialog box to store the values. Then the second dialog box can access them with CWnd* wParent=GetParent(); and wParent->GetDlgItemText(IDCONTROL, String);
But this seems really contrived and kludgy.
I tried using Class Wizard to create member variables, but I could only see controls listed.
Is this workaround I have been using really the way to store variables that are accessible by child windows?
|
|
|
|
|
I either pass the values into the second dialog box or pass a pointer to the first dialog box to the second dialog box.
John
|
|
|
|
|
My example showed the use of a pointer to the first window - the CWnd* wParent = Getparent(); so I didn't need to pass the variable - but how do you pass a value to the second dialog? When I call dlg.DoModal() it doesn't allow for parameter passing.
|
|
|
|
|
Set your values in the second dialog before you call do modal.
CDlg1::OnOK()
{
CMyDlg dlg2;
dlg2.m_var1 = m_var1;
dlg2.DoModal();
}
John
|
|
|
|
|
That looks like what I was hoping for!
Another question - does that mean I need to create controls and assign variables to the controls on dialog 2 instead of dialog 1 (in which case it is still kludgy)? If not, where do I define m_var1?
I am hoping there is a way to assign simple variables without the superfluos creation of controls that will never even be visible. If that is just the way it is done in MFC then I can live with that, but it just seems like there should be a non control-based way......
|
|
|
|
|
Terry O`Nolley wrote:
I am hoping there is a way to assign simple variables without the superfluos creation of controls that will never even be visible.
You will never have to do that.
John
|
|
|
|
|
Terry O`Nolley wrote:
Another question - does that mean I need to create controls and assign variables to the controls on dialog 2 instead of dialog 1
No you do not.
Terry O`Nolley wrote:
If not, where do I define m_var1?
It depends what you are doing. A CDialog class is a C++ class so you can assign variables just as you would with a C++ class. I am sorry I am not more specific but I am a little confused about what you are trying to accomplish.
[EDIT]
Ok I see what you are doing in the other thread. I'll look at that and see if I have an easy solution.
[/EDIT]
John
|
|
|
|
|
|
This was a good pointer that I have bookmarked. Thanks!
Let me explain what I am doing.
I've incorporated Chris Maunder's excellent CGridCtrl into a project. I query a remote SQL database and populate the grid with the record data. When a user double clicks on a record, another dialog fires up with all of that record's data in it. What that second dialog box needs is the record id from the previous dialog box.
Dialog A: Contains a grid control populated with database rows and a hidden edit control.
When a user double-clicks a row in the grid, the record ID from that row is copied to a hidden edit control. :
SetDlgItemText(IDC_CRECORDID, csKey);
Dialog B: Needs to access the record ID in the edit control from Dialog A:
Cwnd* wParent = GetParent(); // get pointer to Dialog A
CString csKey; // will hold the edit control text
wParent->GetDlgItemText(IDC_CRECORDID, csKey); // get the text
The code above to me seems a lot cleaner than doing all of that variable assigning and editing of the class wizard supplied mappings.
I have no problem with the concept of assigning control member variables, but I still see creating a control just so I can assign a member variable to it just so I can hide it just so I can use it as a storage location for an integer as a kludge.
Isn't there a way to just pass variables from one dialog to another?
|
|
|
|
|
Terry O`Nolley wrote:
Isn't there a way to just pass variables from one dialog to another?
There are lot's of ways. You can do as John said and initialize the variables between the dialog class declaration and the DoModal() call. You can pass the values in via the constructor (write your own constructor, forget about ClassWizard, it is very limited), you could write your own DoModal() function that takes the required parameters, or, if your second dialog is modeless, you can use custom messages.
It seems all you are doing is creating an extra control, with all it's overhead, when all you really need is a CString member variable in your first dialog.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote:
It seems all you are doing is creating an extra control, with all it's overhead, when all you really need is a CString member variable in your first dialog.
And thus the very reason for my post!
|
|
|
|
|
Declare a string in the second dialog to hold the record id (m_strRecordID). Before you call DoModal() for the second dialog set m_strRecordID to the records id.
John
|
|
|
|
|
This is most of the header file for my Dialog 2 (with the afx stuff left out):
#include "GridCtrl_src\GridCtrl.h"<br />
class cContentSourcesGrid : public CDialog<br />
{<br />
public:<br />
CString m_ID; <br />
cContentSourcesGrid(CWnd* pParent = NULL);
enum { IDD = IDD_CONTENTSOURCESGRID };<br />
CEdit m_RecordID;<br />
CGridCtrl m_Grid;<br />
CString m_ID; <br />
<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);<br />
<br />
protected:<br />
CString m_ID; <br />
<br />
virtual BOOL OnInitDialog();<br />
virtual void OnOK();<br />
DECLARE_MESSAGE_MAP()<br />
};
And then I try to assign the the record ID to the variable prior to calling DoModal():
cContentSourcesDialog dlg;<br />
dlg.m_ID = csKey;<br />
dlg.DoModal();
I get the compile error:
C:\DEV\PROJECTS\Tree\cContentSourcesGrid.cpp(121) : error C2039: 'm_ID' : is not a member of 'cContentSourcesDialog'
c:\dev\projects\tree\ccontentsourcesdialog.h(13) : see declaration of 'cContentSourcesDialog'
This is what I tried to do first, but these errors led me to believe that you couldn't add variables to dialog boxes without creating controls first but this seemed so wrong that it lead me to ask the question that started this thread.
|
|
|
|
|
You want to put the variable m_ID as public in the cContentSourcesDialog.
John
|
|
|
|
|
That is what I thought and that is what I tried first ( a day before I started this thread).
Please take a look at my code in my last reply - in bold at the beginning of the public: block in the dialog header file I declare the variable. I also included the source code where I try to assign a value to dlg.M_ID prior to calling dlg.DoModal(). This results in the compiler error I also included.
If it all looks correct then what is my next step? Should I reinstall VIsual C++ - is there some weird compiler switch that might have been inadvertantly set?
|
|
|
|
|
I thought that was the source code for the grid (the first dialog that launches the second). You want to declare the m_ID in the second dialog which from the error is cContentSourcesDialog.
Is this the call that shows the second dialog???
cContentSourcesDialog dlg;
dlg.m_ID = csKey;
dlg.DoModal();
Your change should be in cContentSourcesDialog:
class cContentSourcesDialog : public CDialog
{
public:
CString m_ID;
}
John
|
|
|
|
|
Well - I did a clean and then rebuild all and now it is working........
I don't quite understand.
Thanks much for your help!
|
|
|
|
|
Hello all,
I am calling the store procedure from the VC++ application and like to pass some parameters to the store procedure.
The store procedure executes correctly when i pass hard code values like
(SQLExecDirect(hStmt,(SQLCHAR*)"{call usp_SetPushCheck(1,'A','222xyz')}", SQL_NTS)
how should i pass parameter dynamically?
I am trying to use SQLBindParameter() but i am not getting the desired store procedure result thou i am also not geting any error.
can some one help me in getting correct step/code for passing three arg. as shown above dynamically?
thanks
Prasad
|
|
|
|