|
CString str;
Use str.GetBuffer() and str.ReleaseBuffer()
|
|
|
|
|
I dont how to convert from CString to char buffer but you can get a char by using variablename.GetAt(int CharAt) function
|
|
|
|
|
CString str = "hello world";
char pszStr[50] = {0};
::strcpy(pszStr, <code>(LPCSTR)</code>str);
never use GetBuffer, until you need to modify directly the internal CString buffer. the CString class provides some useful cast operators, such as the one quoted here
|
|
|
|
|
I believe the more correct cast would be LPCTSTR.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I believe the more correct cast would be LPCTSTR
not quite.
LPCTSTR is when dealing with TCHAR. here, i woluntarily used char, because i didn't want to enter unicode types considerations (and i didn't know the equivalent strcpy() function )
|
|
|
|
|
toxcct wrote: (and i didn't know the equivalent strcpy() function )
wcscpy() , or _tcscpy() if you are supporting both.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
toxcct wrote: LPCTSTR is when dealing with TCHAR
If you're using CString then you're using TCHAR.
For CString, LPCTSTR is appropriate.
For CStringA. LPCSTR would be ok.
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
No cast is needed in this situation, the following code works identically:
CString str = "hello world";
char pszStr[50] = {0};
::strcpy(pszStr, str);
Casts which are not needed – especially when they are C-style casts – are a pet hate of mine. Note the whole LPCTSTR vs LPCSTR is no longer an issue as such.
Steve
|
|
|
|
|
yaminisridaran wrote:
I am implementing a CString object and I want to convert a string in CString to char buffer.
CString str;
char* pBuffer= (LPSTR)(LPCTSTR)str;
|
|
|
|
|
link
in this code how can one call the button clicked function on pressing enter. i have tried adding virtual void OnOK(); but still the enter key doesn't execute the button function but now the dialog is not closing.
I have used a CxSkinbutton class which creates button with different skins. do i need to add a function in that class to capture the enter key
vimarsh
-- modified at 4:39 Wednesday 4th April, 2007
|
|
|
|
|
I didnt check the CxSkinbutton and all...
But wish to tell you that, if the return vaue of the WM_GETDLGCODE message send to the button didnt contain the DLGC_DEFPUSHBUTTON values set, the button will not respond for the enter key. Try overidding the WM_GETDLGCODE message and passing DLGC_DEFPUSHBUTTON too with it..
UINT CxSkinbutton::OnGetDlgCode()<br />
{<br />
return CButton::OnGetDlgCode()| DLGC_DEFPUSHBUTTON ;<br />
}
nave
|
|
|
|
|
i added the code that you wrote it still doesnt work
|
|
|
|
|
did u added the message map entry? Its not a virtual function. you need to add
ON_WM_GETDLGCODE() inside the message map.
nave
|
|
|
|
|
now the skin of the button is gone,but the enter key is working
|
|
|
|
|
I dont know what they have done in the CxSkinbutton
nave
|
|
|
|
|
thanx any ways, let me know if get something
|
|
|
|
|
Hi,
i used the article about the MemDC (http://www.codeproject.com/gdi/bufferdc.asp).
I used the MemDC class and i have also a sideeffect, the background of the view is drawn black.
In the OnInitialUpdate class i put a CLIP_CHILDREN.
At the OnSize-Handler i resize all my controls via MoveWindow(......,FALSE); then i practice a RedrawWindow();
The OnDraw-Handler is modified as it's described. ( i don't have a particulary function which draws the controls explicitely)
Does anyone has an idea?
Does i need to redraw the background in the OnDraw-Handler via CDC *pDC ? But how
Big thanks
|
|
|
|
|
The default of a DC is a monochrome bit map, so that is probably the problem.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Thanks for your reply
The background color is "lighter blue" so it's possible that the blue is replaced with black in monochrome...
What i need to do to change that the DC isn't in monochrome? or that the background is drawn correctly in lighter blue
Big thanks
|
|
|
|
|
Hi ,
I want with use asm command (in out) in VC send my value to parallel port,
my OS is windows X64 and when send to parallel port , get a OS Error.
|
|
|
|
|
You can't use in / out in Windows programs. Only drivers are allowed to access hardware at that level. If you search on the web, you'll find various programs that will allow you to write to the parallel port. They've already done the work of writing the driver and provide you with an API to call from a Windows program.
Judy
|
|
|
|
|
I have gwiopm.sys file get from internet and with this .sys file can use in / out asm command and sent data to parallel port from application Win32 , now i want send my data to parallel port from windows X64.
|
|
|
|
|
I was wondering if there's any way to manually create a modal window without the use of the DialogBox function and it's variations. And i'm not talking about manually creating the dialog with DLGTEMPLATE, but rather applying modal properties to an already created window.
Does anybody have an idea about how it could be done?
|
|
|
|
|
Just to be sure: you don't use MFC and you work only with the win32 API ?
|
|
|
|
|
Right, i'm using only winapi.
|
|
|
|