|
you are wellcome
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
|
|
|
|
|
Hi,
I have created a static variable in a vc++6.0 project, the same project has sub project workspace. The variable which was created in one workspace is not accessible in another, though all are successfully compiled.
what could be the reason ?
Thanks and regards,
Thanks a lot
|
|
|
|
|
ganesa moorthy wrote: what could be the reason ?
The reason is that you were absent the day they taught C++ in C++ class. That's a C++ basic beginners topic (static scope[^]) and if you have not yet learned it then I hope your project is a school project.
led mike
|
|
|
|
|
try it in two different workspaces, it will work within one workspace only.
Thanks a lot
|
|
|
|
|
You really have to get yourself a book about C/C++ basics.
|
|
|
|
|
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.
|
|
|
|