|
Wow - that's a lot of code, thanks for going to this effort for me.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
I create a table A in the Oracle.
CREATE TABLE A
(
ID NUMBER(7) primary key
);
Now ,I want to insert a reocrd in the table A;
_ConnectionPtr pConn=NULL;
pConn.CreateInstance(__uuidof(Connection));
_RecordsetPtr pRst=NULL;
pRst.CreateInstance(__uuidof(Recordset));
pConn->Provider="OraOLEDB.Oracle.1";
try
{
pConn->Open("","ISVISION","ISVISION",NULL);
pRst->CursorLocation=adUseClient;
pRst->Open("A",pConn.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdTable);
pRst->AddNew();
pRst->Fields->Item[0L]->Value=100L; //But it throw a excpetion here. I dont know the reason. If I alter the datatype of ID to CHAR(10),it is all right.
//这里就会出现异常,如果表A的ID的数据类型是CHAR(10)的,又不会出错?
pRst->Update();
pRst->Close();
pConn->Close();
}
catch (_com_error& e)
{
MessageBox(e.Description(),"error",MB_OK|MB_ICONWARNING);
return ;
}
if (pConn)
pConn.Release();
if (pRst)
pRst.Release();
|
|
|
|
|
I am trying to maintain someone elses code and do not fully understand it's nuances. However I am trying to recover a string stored in a CComboBox list.
I posted this at little earlier at 19:50 but some of the code was missing/corrupted
//---------------------------------
void Control::DoDataExchange(CDataExchange* pDX)
{
Sheet* pSheet = ((C_App*)AfxGetApp())->getSheet();
MyPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Control)
DDX_Control(pDX, IDC_OTHER_COMBO, m_otherCombo); // IDC_OTHER_COMBO is the CComboBox ID:
//}}AFX_DATA_MAP
}
//---------------------------------
//Sheet::PopulateOtherCombo()
{
int i;
int entry=0;
int index=0;
CString name;
for (i=0;i<maxcount;i++)
{
="" some="" code="" that="" constructs="" the="" string="" 'name'
=""
="" write="" 'name'="" to="" ccombobox
index="getControl()-">m_otherCombo.AddString(name);
if (index != CB_ERR)
{
getControl()->m_otherCombo.SetItemData(index, entry++);
}
}
}
//---------------------------------------------------------------------------
//So far I have built a list of strings stored sequentially by 'index' but how do I recover a string ??
// When I click on the CComboBox, the list opens and I can select any of the entries.
int index = getControl()->m_otherCombo.GetCurSel();
// Gets the index # of the currently selected CComboBox entry.
// Now I want to copy the text of the currently selected entry somewhere else.
// I have the index but there is no GetString(index) function
// HELP!
Thanks for any help you can offer
Charles
|
|
|
|
|
The code gets 'corrupted' because you didn't check the box that says 'Do not treat <'s as HTML tags'. Edit this post so we can see the code, then you may get a reply
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
new to the forum. I'll look for it next time. meanwhile Brad Bruce suggested GetLBText. thanks anyway
|
|
|
|
|
|
Thqanks Brad
works great
|
|
|
|
|
If by 'recover' you mean get the currently selected item in the combobox, I use GetWindowText() .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
sorry some code went missing when I pasted.. here it is again
void Control::DoDataExchange(CDataExchange* pDX)
{
Sheet* pSheet = ((C_App*)AfxGetApp())->getSheet();
MyPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Control)
DDX_Control(pDX, IDC_OTHER_COMBO, m_otherCombo); // IDC_OTHER_COMBO is the CComboBox ID:
//}}AFX_DATA_MAP
}
//-----------------------------------------------------------------
Sheet::PopulateOtherCombo()
{
int i;
int entry=0;
int index=0;
CString name;
for (i=0;i<max_count;i++)
{
=""
="" some="" code="" that="" constructs="" the="" string="" 'name'
=""
="" write="" 'name'="" to="" ccombobox
="" index="getControl()-">m_otherCombo.AddString(name);
if (index != CB_ERR)
{
getControl()->m_otherCombo.SetItemData(index, entry++);
}
}
}
//---------------------------------------------------------------------------
//So far I have built a list of strings stored sequentially by 'index' but how do I recover a string ??
// When I click on the CComboBox, the list opens and I can select one of the entries
int index = getControl()->m_otherCombo.GetCurSel();
// Gets the index # of the currently selected CComboBox entry.
// Now I want to copy the text of the currently selected entry somewhere else.
// I have the index but there is no GetString(index) function
// HELP!
|
|
|
|
|
what function would take
int i = 36;
to a char c?
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
|
as suggested, char c = (char)i; is correct but can cause a warning as you could lost some data.
char (which mean signed char ) can contain values from -128 to +127, so any value of your int that is out of bound would be truncated...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
as suggested, char c = (char)i; is correct but can cause a warning as you could lost some data.
char (which mean signed char) can contain values from -128 to +127, so any value of your int that is out of bound would be truncated...
Since an int is 4 times the size of a char, the value will always be truncated! One way to make sure that your value has the same sign bit as the previous int variable is:
c = (i & 0x80000000) ? c | 0x80 : c & 0x7F
Here your test the sign bit i & 0x80000000 . Depending on it is set, you set or remove the sign bit from the char.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
when you copy a signed integer (either char , short , int or long ), the sign bit is copied too...
so, making this will work without any data loss :
int i = -2;
char c = (char) i;
ASSERT(c == -2);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
when you copy a signed integer (either char, short, int or long), the sign bit is copied too...
I just verified it and shame on me...
Thanks for pointing that out!
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi,
You can Use ltoa function.
//////////////////////////
char ch[256];
ltoa(1234,ch,10);
//////////////////////////
cheers.
|
|
|
|
|
I have a scenario where the size and position of a warning dialog is inconsistent depending on what is done with a modeless dialog that produces it. I have a modeless dialog that has a combo box that fires a kill focus event. If I tab out of the combo box the warning pops as expected centered over the parent modeless dialog centered both horizontally and vertically.
If I highlight the combo box, then click and drag the modeless dialog by its caption bar the kill focus fires as expected. However, the popup warning is now half the size and off to the left of the modeless dialog that produced it. It appears to be centered on the Windows desktop instead of my application dialog.
I have tried it as MessageBox, AfxMessageBox, and as a custom dialog we use for warnings and errors (Just a MessageBox with some custom bells and whistles). All produce the same weird positioning behavior.
Is this a quirk with MFC or Windows?
Is there any way for me to obtain a handle to a pop up dialog, such as AfxMessageBox and position it myself?
Is there some simple reason/solution I am just not seeing?
The app is written in VC++ 6. This is just an annoyance and does not effect the functionality of the app, it is just bugging me, help.
Thanks,
Troy
|
|
|
|
|
Vector but I would to define a foreach statement
std::vector<cworddata*>::iterator itNum = this->_arrWords.begin();
for(; itNum < this->_arrWords.end();itNum++ )
how would I change it to said like so
foreach( myObject obj in this->_arrWords )
I know I would use a define but what else>
please help.
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
No, why would you do such an abomination ? Someone has done it as an article already, if you must try to force the issue. Instead, you should use for_each[^], which will allow you to write a function object to define the action you want to take on each object, using C++ instead of trying to hack it into looking like C#.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
sorry I didn't know. But this looks perfect.
I'm glad I asked.
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Ista wrote:
I'm glad I asked.
*grin* Glad to help. Sorry if I seemed rude, I just hate overuse of macros
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi!
How to change the screen cursor with a custom cursor?
I don't want to change the cursor into my main window, but for all applications, wherever the cursor is.
Thks in advance!
Appstmd
http://www.atlence.com
|
|
|
|
|
Atlence wrote:
...but for all applications, wherever the cursor is.
Wouldn't you need SetCapture() for this?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
This function doesn't work, because it changes only the cursor when it is over my application. I want to change the cursor even if the cursor is out of my window application!
Thks in advance!
Appstmd
http://www.atlence.com
|
|
|
|