|
thanks i need to learn a lot, but do u know it is possible to retain and have values of static variable in project but across workspaces.
Thanks a lot
|
|
|
|
|
Hi ,
I want to connect Sqlserver Rdbms through vc++(MFC).What r the settings that I want to made.please mention the possible ways to do this
Like using ADO or OLEDB or what r the classes that i can use for this
ramesh
|
|
|
|
|
Click here -> [^]
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Hope this should find ur way
_variant_t var1, var2 //if needed;
HRESULT hr = S_OK;
int icUserID;
BOOL bFound;
bFound=FALSE;
if(FAILED(::CoInitialize(NULL)))
//AfxMessageBox("Error");
_ConnectionPtr pConnection2 = NULL;
TESTHR(pConnection2.CreateInstance(__uuidof(Connection)));
pConnection2->ConnectionString = "DSN=URDSN;UID="";PWD="URPW";";
pConnection2->Open("","","",adConnectUnspecified);
_RecordsetPtr pRstUser = NULL;
hr = pRstUser.CreateInstance(__uuidof(Recordset));
if(FAILED(hr))
{
//AfxMessageBox("Unable to Open the Record Set.");
}
bstr_t sqlStatement1;
sqlStatement1 = "SELECT * FROM URTABLE"; //what every
// what every...
pRstUser->Close();
pConnection2->Close();
CoUninitialize();
|
|
|
|
|
Did you see Database section on the codeproject it has lot of articles.
|
|
|
|
|
Can any body tell me how to convert UPPER case string to lower case string in Unicode.
I need to convert Russian language. They have upper and lower case and MakeLower / _tcslwr in not working on russian. Do you have any other solution.
|
|
|
|
|
All reposts will be ignored. Besides that, I gave you an answer here[^].
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
If previous answers are'nt helpful for you,you reply to them.
|
|
|
|
|
LPCTSTR CSample1Dlg::GetTheComputerName()
{
TCHAR infoBuf[MAX_COMPUTERNAME_LENGTH + 1];
DWORD bufCharCount = MAX_COMPUTERNAME_LENGTH;
GetComputerName( infoBuf, &bufCharCount );
return (infoBuf); //Here infoBuf = "XYZComputer" (which is
the computer name)
}
.
.
LPCTSTR lpstr = GetTheComputerName(); //Here lpstr = "XYZComputer"
CString csComputerName(_T("");
csComputerName = CString(lpstr, 15); //Here csComputerName = Garbage
How can I have the computer name in csComputerName (which is a
CString)?
|
|
|
|
|
What the '15' you pass in the constructor of the CString ? Just remove it and it will be fine.
How do you check that csComputerName is garbage ?
|
|
|
|
|
Thanks for the reply.
I've used one of the prototypes of CString constructors that is :
CString( LPCTSTR lpch, int nLength );
The 15 specified is just an hard-coded value of nLength.
I tried removing nLength as you suggested, but didn't work.
How do you check that csComputerName is garbage ?
Ans : By way of debugging
|
|
|
|
|
I found that the pointer to 'infoBuf' was getting lost as soon as the 'GetTheComputerName()'
returned.
There are 2 ways to resolve this :
1) Declare TCHAR infoBuf[MAX_COMPUTERNAME_LENGTH + 1]; in a .h file as a data member.
OR
2) Make 'infoBuf' as static if it is locally declared within 'GetTheComputerName()'
Thanks for your support.
|
|
|
|
|
SherTeks wrote: I found that the pointer to 'infoBuf' was getting lost as soon as the 'GetTheComputerName()'
returned.
Because in the CSample1Dlg::GetTheComputerName() you are returning the stack variable - infoBuf. The stack variables will get deleted when the function returns.
SherTeks wrote: There are 2 ways to resolve this :
1) Declare TCHAR infoBuf[MAX_COMPUTERNAME_LENGTH + 1]; in a .h file as a data member.
OR
2) Make 'infoBuf' as static if it is locally declared within 'GetTheComputerName()'
I can suggest another method. Pass a CString by reference to the function. Then inside the function, get the computer name and assign to CString param. For instance see the code snippet.
void CSample1Dlg::GetTheComputerName( CString& csComputerName )
{
TCHAR infoBuf[MAX_COMPUTERNAME_LENGTH + 1];
DWORD bufCharCount = MAX_COMPUTERNAME_LENGTH;
GetComputerName( infoBuf, &bufCharCount );
csComputerName = infoBuf;
}
...
CString csComputerName;
GetTheComputerName( csComputerName );
________________________________
http://weseetips.com - Visual C++ technical tips.
|
|
|
|
|
Thanks for the suggestion.
|
|
|
|
|
Can someone please point me to the source of info on how to control Edit box cursor?
Function SetDlgItemText(....) sets the text fine but moves the cursor to the beginning of the text. I need the cursor at the end of the set string.
Also would like to be able to erase/delete all current text using ESC or Delete keys only. The "default" Enter key is "routed" to default button. How to I intercept this message?
Thanks for your help.
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: I need the cursor at the end of the set string.
HWND hwndDlg;
HWND hwndEdit = ::GetDlgItem(hwndDlg, IDC_EDIT1);
const TCHAR *szText = _T("Edit Box String");
int nSelPos = _tcslen(szText);
::SetWindowText(hwndEdit, szText);
::SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndEdit, TRUE);
::SendMessage(hwndEdit, EM_SETSEL , (WPARAM)nSelPos, (LPARAM)nSelPos);
::SendMessage(hwndEdit, (UINT) EM_SCROLLCARET, (WPARAM) 0, (LPARAM) 0);
modified on Friday, May 23, 2008 12:08 PM
|
|
|
|
|
Thank you, works almost as advertised!
Looks like a typo "(WPARAM)m_wndEdit.m_hWnd,", but I already have a focus so I did not need to send this message anyway.
I would have a tough time figuring this out myself, you are very helpful. Thanks again.
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Looks like a typo "(WPARAM)m_wndEdit.m_hWnd,
yes, i just coded this for MFC, and I assume you were not using MFC, i mapped to win32 soon, Corrected now.
|
|
|
|
|
Rajkumar,
No problem, I did modify your code and it does what I wanted to do.
There is a minor bug in it - after the cursor is moved I can no longer backspace in the Edit box. I'll try to figure out how to do that.
Thanks for your input.
Cheers Vaclav
|
|
|
|
|
what happens when backspace is pressed, what if other keys pressed, i can able to backspace and delete the characters, how do you setfocus, and where you are sending those messages.
|
|
|
|
|
The problem is not with the text / cursor insertion. I have another problem with my program.
When I insert the text and cursor (result of SQL search)and than attempt to do backspace my application continues to do SQL lookups on the inserted text in the list box and gets "out of control" causing it to reinsert the last text.
I'll need to work on that. I'll let you know after I fix it.
Vaclav
|
|
|
|
|
Can any body tell me how to convert UPPER case string to lower case string in Unicode.
|
|
|
|
|
|
sumit.durg wrote: Can any body tell me how to convert UPPER case string to lower case string in Unicode.
CString has the MakeUpper() and MakeLower() functions, but you need to understand that upper case and lower case exists only in English (and may be in those languages that uses English script). It is not a very good idea to make this call on a language like Hindi. I believe you understand it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
For other languages, could be it done just adding or decreasing the "letter value" by 34 (or whatever value that gives "A" - "a")?
Missunderstood of previous answer
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|