|
thanks for your help,but I want to use this method without importing ado.dll:
CString m_strConnect.Format("Provider=OraOLEDB.Oracle.1;Password=user_password;Persist Security Info=True;User ID=user_id;Data Source=user_DATASource;");
_RecordsetPtr m_prs;
_ConnectionPtr m_pConnection;
HRESULT hr = S_OK;
try
{
hr = m_prs.CreateInstance(__uuidof(Recordset));
if(FAILED(hr))
{
AfxMessageBox("记录集对象建立失败!",MB_ICONINFORMATION);
return ;
}
BeginWaitCursor();
m_strSQL = "select * from tableA";
hr = m_prs->Open(_bstr_t(m_strSQL),(IDispatch*)m_pConnection,adOpenStatic ,adLockReadOnly,adCmdText);
if(FAILED(hr))
{
AfxMessageBox("数据库查询失败!",MB_ICONINFORMATION);
return ;
}
EndWaitCursor();
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("错误信息:%s",(char*)(e.Description()));
AfxMessageBox(errormessage, MB_ICONINFORMATION);
return;
}
catch (CException err)
{
err.ReportError();
return;
}
catch(...)
{
AfxMessageBox("未知错误!",MB_ICONINFORMATION);
return;
}
compiles show errors:_ConnectionPtr not definition
|
|
|
|
|
i use spin control to spin a opengl dialog box based aplication (rectangle object), i put info about spin control value to a static text, i set range from -90 to 90, it's run normal wen run from 90 - 0(left to right(clock arrow)), but when value -1 (on static text info) the rectangle object JUMP BACK from 0 position back to aprox ~ +20 (JUMP BACK right to left(back of clock arrow)) then at -2, -3, -4 ... etc run continue from -1 position from left to right(clock arrow again),
somebody help me please , or can you help me code to run spin control to move/spin object on a opengl dialog box aplication.
|
|
|
|
|
i use spin control to spin a opengl dialog box based aplication (rectangle object), it put info about spin control value to a static text, i set range from -90 to 90, it's run normal wen run from 90 - 0(left to right(clock arrow)), but when value -1 (on static text info) the rectangle object JUMP BACK from 0 position back to aprox ~ +20 (JUMP BACK right to left(back of clock arrow)) then at -2, -3, -4 ... etc run continue from -1 position from left to right(clock arrow again),
somebody help me please , or can you help me code to run spin control to move/spin object on a opengl dialog box aplication. ???
|
|
|
|
|
I have to write a program to turn off the hard disk immediately.
Is there any Windows API for controlling the hard disk?
I surf on the internet, and I got a utility - Hard Disk Sleeper.
It can turn off hard disk immediately.
Does anybody know how it achieves that?
Thanks !
Jesa
|
|
|
|
|
My first guess would be to create a (temporary) policy using CallNtPowerInformation() . Set the SpindownTimeout member of SYSTEM_POWER_POLICY to 0.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I look up the MSDN, this way can not turn off hard disk immediately.
When we set the SpindownTimeout to "0" ,then the result is set to "Never".
It seems that the minimum value of SpindownTimeout is 180 (3 mins).
Jesa
|
|
|
|
|
Are your results from actual testing or some Internet site? I found SpindownTimeout mentioned in only one place in MSDN. While it makes no mention of 0, which could very well mean "never," a one-second delay would not be noticeable.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have checked several pages on here and on other sites about returning values from calling a dialog. Some sites say "use UpdateData" and others say "don't use UpdateData". I try both ways and neither of them work so either I'm not implementing either way right or there's a third way I don't know. Here's the DoDataExchange function that's in the dialog that I call (the child):
void CCompressionTest::DoDataExchange(CDataExchange* pDX) {<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_DOUBLE_COMBO, m_doubleComboBox);<br />
DDX_Control(pDX, IDC_SINGLE_COMBO, m_singleComboBox);<br />
DDX_Radio(pDX, IDC_SINGLE_RADIO, m_compressionRadio);<br />
}
Here's the code where it's called by the parent and then used:
CCompressionTest dialog;<br />
if (dialog.DoModal()) {<br />
CString message;<br />
message.Format("val1: %u\nval2: %u\nval3: %u", dialog.m_compressionRadio, dialog.m_singleComboInt, dialog.m_doubleComboInt);<br />
AfxMessageBox(message, MB_OK);<br />
}
When I type "dialog.", the variables show up in the list so I know it is aware of the variables, but the result is all zeroes. I've spun my wheels for long enough and I am asking for help. Thanks in advance, Nate.
|
|
|
|
|
The second two variables you're printing out aren't in the data exchange list, so they won't have any data in at all. The first should have though. Have you tried selecting different radio buttons and seeing what is printed out?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I added the two variables under "Add Variables...", they are public shorts and thought it was more automatic than that. How do I add the second two variables? I thought when I added them, it sent them through like it should with the radio button? Yes I've tried other radio buttons, I only have two so I guess that's why it's a boolean value instead of integer.
edit: I added two new variables, they were private value integer variables but I just moved their declarations from private to public. They can now tell me which numbered item was selected which I can deal with. However, the radio button is still not working. I go to the Add Variables wizard but it still keeps forcing me to choose a boolean value for the radio buttons and changing the selection doesn't seem to change the value of the radio button variable.
|
|
|
|
|
LighthouseJ wrote:
Some sites say "use UpdateData" and others say "don't use UpdateData".
Calling UpdateData() manually can invite lots of problems. When it's called automatically by OnOK() , that's fine.
What types are m_compressionRadio , m_singleComboInt , and m_doubleComboInt ? Can you verify that the three statements in DoDataExchange() are being called after the OK button has been clicked?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you for your response. I fixed the combo values with the other reply in this thread and just now I realized that I set the "Group" property for both radio buttons but remembered only the radio that has the member value that will be returned should have the Group property set. The results fully work now, thanks again.
|
|
|
|
|
Hey all,
I've been toying with making a TCP connection and sending and receiving strings for a couple of days now. I've finally gotten to the point where I can initiate a connection, send some data, and receive some data (I pretty much have a WHILE loop in there listening for certain strings coming back). I'm doing it in the manner of:
CSocket mySocket;
if (mySocket.Connect("192.168.1.105",2000)) {
// while ...
// mySocket.Send();
// mySocket.Receive();
}
All I'm using is CSocket::Connect, Send and Receive. It's working great. I've been stuck for a day now on how to detect when that socket has been closed. (IE, I physically disconnect the LAN cable on the 192.168.1.105 PC). I cannot figure out how to do this. I've read a bunch of articles, and I simply cannot get it to work. I was hoping there was some sort of " if mySocket.IsStillOpen() .... " method existed, but I cannot find one. I'm not sure how to proceeed and was looking for a pointer in the right direction. Any help is extremely appreciated, as this has been a long road to do what seems to be a simple task (I guess I'm a slow learner!)
Thanks much in advance
|
|
|
|
|
I'm not an expert here but the OnSend member should return a value of WSAENOTCONN if you try to send data to a remote you're not connected to. I'm sure it will return something other than success if the cable is unplugged during the transmission. Are you checking return values?
|
|
|
|
|
Sometimes, if I do mySocket.Receive ..... and the socket disconnects (ie, I do a mySocket.Receive... and the socket is still connected, but the remote end has not sent anything ... and I disconnect the LAN cable, dropping the connection ...) the program just sits and hands on the mySocket.Receive() code. (I have a "MessageBox()" before and after the receive statement, so I can tell that it gets to there, and then it's like it tries to listen for data, even though the connection has failed, and never exits out of that receive method. I'm wondering how I can get around this??
|
|
|
|
|
|
Unplugging the network cable doesn't close a socket. Plug the cable back and data transfer should continue, TCP/IP is designed to handle unreliable physical connections.
|
|
|
|
|
hi,
on my application i have lib file for toolbar and i want host( attach ) this lib file to Internet Explorer but i dont know how
thanks
|
|
|
|
|
I am doing a printscreen, but would like to delay call by 1 s. What function can I call to delay execution for 1 s?
|
|
|
|
|
sleep() or sleepEx()
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
This is the part of program I need a slight time delay without the client knowing a time delay exists. Here is the code segment I have problems with The message box does not appear on first printout, only on subsequent ones.
void CWaterHammer::OnBnClickedPrint()
{
CPrntScreen * ScrCap;
ScrCap = new CPrntScreen();
m_caveat="This publication is intended for use as a piping system guide. It should not be used in place of a professional engineer’s judgment or advice and it is not intended as installation instructions. ";
GetDlgItem(IDC_EDIT2)->ShowWindow(true);
CEdit* pCEditBox = (CEdit*)this->GetDlgItem(IDC_EDIT2);
pCEditBox->SetWindowText(m_caveat);
ScrCap->DoPrntScreen(1,0,true); //Client area, Printer menu
delete ScrCap;
ScrCap = NULL;
}
|
|
|
|
|
What I want to do is wait to call prsntscreen until the text appears on the screen. SetWindowText returns an error code, how can I use this?
|
|
|
|
|
Must the text appear on the screen before capturing it? How about adding the text to the captured screenshot?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
There is a delay in the text appearing before the next fuction is called to do the screenshot. I Even used GetErrorMsg(), which released a non-error code from SetWindowText(..) call. Thus, this is not applicable, since text appearing on client screen and executable are out of sync. I also tried using Sleep() in PrinScreen function, this affected the text appearing on screen as well. Go figure.
Yes the only solution is to append the text to the captured and printed bitmap before releasing printer. Another function call needs to be made to do this, it would be similiar to sizing the bitmap image after screen capture.
Thank you,
Diana
|
|
|
|
|
DiMats wrote:
Yes the only solution is to append the text to the captured and printed bitmap
See my article on rendering text on a bitmap for how to do this.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|