|
|
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
|
|
|
|
|
CString str;
str.Format("{call usp_SetPushCheck(%d,'%c','%s')}", 1, 'A', "222xyz");
(SQLExecDirect(hStmt,(SQLCHAR *) str, SQL_NTS)
|
|
|
|
|
I am using SQL 2000 and VC.net. I have an image field in my table together with 2 binary fields.
The first process in my app adds a jpg image to the table and the second app does some image processing
resulting in two CByteArray values which needs to be handled via the RFX_Binary call. For some reason,
calling the recordset update function I get a message "Error: field address (column %u) has changed!\n".
I tried the msdn but this just states that the bug has been fixed. Is this me making a mistake or what is going on here.
Table1.Edit();
//Initialise the m_ByteArray1 and m_ByteArray2 of Table1 whith some procedure
Table1.SetFieldDirty(&Table1.m_ByteArray1);
Table1.SetFieldNull(&Table1.m_ByteArray1, FALSE);
Table1.SetFieldDirty(&Table1.m_ByteArray2);
Table1.SetFieldNull(&Table1.m_ByteArray2, FALSE);
Table1.Update();
//Calling the above Update, assetrs with "Error: field address ...."
Please give me some direction, appreciate
|
|
|
|
|
Hello, this is probably a rather stupid question but I've been having problems with it for a couple of days...
I have to send a message over a TCP/IP conection, i.e. sockets...the message that I must send should have a header and a trailer, the message structure is this:
<esc><esc><esc><stx><message><esc><esc><esc><etx>13<null>
I found on asciitable.com that ESC, STX, and ETX have a decimal int value of 27, 2 and 3 respectively...
I have declare the array like this:
char message[]={27,27,27,2,'h','e','l','l','o',27,27,27,3};
when I compile it marks errors, how can I address ESC, STX and ETX in a char array????
|
|
|
|
|
char message[]={'\033','\033','\033','\002','h','e','l','l','o','\033','\033','\033','\003'};
the '\033' is the octal value for ESC dec 27
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
char message[] = "\0x1b\0x1b\0x1b\0x02hello\0x1b\0x1b\0x1b\0x03";
|
|
|
|
|
edujule wrote:
char message[]={27,27,27,2,'h','e','l','l','o',27,27,27,3};
when I compile it marks errors,
I get none. Please list the compiler error(s).
|
|
|
|
|
If I want to add an browse functionality in my dialog box, how can we do that??
|
|
|
|
|
What is a browse functionality?
Kuphryn
|
|
|
|
|
The usual way is to add a button with three dots (or the word "Browse"). Add a ON_BN_CLICKED message handler for the button, and within the handler call SHBrowseForFolder or CFileDialog. Search CP for examples of both.
HPS HwndSpy - GUI developer's aid to visually
locate and inspect windows. For the month of August
only, use coupon code CP-81239 for 30% off.
|
|
|
|
|
Hello!
In your dialog box, have a button where the user clicks and have that button execute this code:
void your_class_name_here::OnButtonClick()
{
CFileDialog m_file(TRUE);
CString m_value;
if(m_file.DoModal() == IDOK)
{
// get file selected
m_value = m_file.GetFileName();
UpdateData(FALSE);
}
// add whatever else you need
}
Hope that helps!
Caleb
|
|
|
|
|
and how to change font of and Titlebar of MDIChild
is there a another way than use SystemParamenterInfo()
help me .......thanks
|
|
|
|
|
I have been messing around with sockets for a while now but still can't get the code right to display ONLY the servers on a network.
How do I tell them apart from normal terminals??
Thanks.
|
|
|
|
|
What functions are you using?
Take a look at NetServerEnum()
using SV_TYPE_SERVER_NT & SV_TYPE_DOMAIN_CTRL & SV_TYPE_DOMAIN_BAKCTRL
- Anders
Money talks, but all mine ever says is "Goodbye!"
http://SourceLocker.net[^] SourceControl and DefectTracker Project.
nsms@spyf.dk <- Spam Collecting
|
|
|
|
|
Hello all,
I'm new to device programming and am pleading for somebody to help me with this problem. I own a Fujitsu N-Series Lifebook (N3010) which has an Application Panel (extra buttons for quick access to programs). I am currently trying to write a program that uses the Application Panel for specific hotkeys. Unfortunately, the only resources I have for accessing this panel is available for Linux systems (apanel.sourceforge.com), and that code is actually a device driver. I want to use the built-in device driver, but do not know how to access the device. If anybody could tell me how I am to interface with the driver and access the device, your help is greatly appreciated. Btw, I do not have the source code on the functions, defines, etc of the device driver, which is a .SYS file. Thank you!
Zero_Divide_1
|
|
|
|