|
Of course it depends on what you choose as a suitable string. For instance C-like strings are simply (NULL-terminated) character arrays, hence you can do something like:
char ** myStringArray;
myStringArray = new char * [3];
myStringArray[0] = "hello world";
myStringArray[1] = new char[10];
memset(myStringArray[1], '*',9);
myStringArray[1][9]='\0';
myStringArray[2] = strdup("Hi");
delete [] myStringArray[1];
free (myStringArray[2]);
delete [] myStringArray;
On the other hand, MFC CString or std::string are objects controlling themselves the inner character buffer, therefore you can do, for instance:
CString * myStringArray;
myStringArray = new CString[2];
myStringArray[0]="Hello World";
myStringArray[0] += "!";
myStringArray[1]=CString('*',9);
delete [] myStringArray;
Hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Working with this for a couple days, I wish I were smarter about this stuff. Please help:
double x;
TCHAR TcharTestString[50];
GetDlgItemText(hDlg,IDC_STATIC_A, &TcharTestString, 8 );
x = wcstod(&TcharTestString, &stopstring);
printf("strtod = %f\n", x ); //everything okay so far
swprintf(&TcharTestString, "%f", x); // just won't work
Thanks
|
|
|
|
|
An array of TCHAR is already a string, don't use & when passing that variable to a function.
|
|
|
|
|
frqftgbdafr wrote: double x;
TCHAR TcharTestString[50];
GetDlgItemText(hDlg,IDC_STATIC_A, &TcharTestString, 8 );
x = wcstod(&TcharTestString, &stopstring);
printf("strtod = %f\n", x ); //everything okay so far
swprintf(&TcharTestString, "%f", x); // just won't work
Just a suggestion.
When using TCHAR always use functions defined for TCHAR's .
For eg: _tcstod for wcstod , _stprintf for swprintf , _tprintf for printf etc.
Or if you are sure that you want a wide char type then instead of TCHAR directly use wchar_t .
Once again, use TCHAR with functions defined for TCHAR's .
|
|
|
|
|
Each list view is associated with a list control which we can access by calling GetListCtrl().
How to set this list control to use LVS_OWNERDATA style ?
I've tried to put these in OnCreate or OnInitialUpdate but it didn't work. The list is still not of OWNERDATA style.
CListCtrl &ctlTmp = this->GetListCtrl();
ctlTmp.ModifyStyle(NULL, LVS_REPORT | LVS_OWNERDATA);
how could I do this ?
|
|
|
|
|
You can't dynamically set this style - it has to be set when the control is created.
You can pass it with the dwStyle parameter to Create()/CreateEx() or set it in the resource editor
properties if it's a control on a dialog resource.
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Mark Salsbery wrote: You can pass it with the dwStyle parameter to Create()/CreateEx() or set it in the resource editor
properties if it's a control on a dialog resource.
yeah, if it was a list control in a normal dialog then it would be easy.
But for a list view and its associated list control, I dont' know where and when the list control is created to set its style.
GP
|
|
|
|
|
In a CListView derived class, override PreCreateWindow()...
BOOL CMyListView::PreCreateWindow(CREATESTRUCT& cs)
{
if (CListView::PreCreateWindow(cs))
{
cs.style |= LVS_OWNERDATA;
return TRUE;
}
return FALSE;
}
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Thanks Mark, it works so charming now
I give u a 5-star vote
|
|
|
|
|
I want to handle the close button click of a Dialog based application.
How to do this and how message map should look like.
Best Regards,
Suman
|
|
|
|
|
You can override CDialog::OnCancel().
or
ON_WM_SYSCOMMAND()
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
void CMyDialog::OnSysCommand(UINT nID, LPARAM lParam)
{
if (nID == SC_CLOSE)
{
}
CDialog::OnSysCommand(nID, lParam);
}
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi Mark, It is working. Thank you very much for your fast and great help.
Best Regards,
Suman
|
|
|
|
|
i need to know all the key words when searching for Temporary Internet Files. i know "cookie:" and "visited:" i know i could use *.* but i need to be able to search for each type by its self. i tryed "temporary:" but its the same as "*.*" so if you know any or a link that shows more please post it.
|
|
|
|
|
|
Why is it necessary to have a constructor with no arguements if we have the DECLARE_SERIAL macro defined for serialible classes.
|
|
|
|
|
A default constructor is necessary because when un-serializing (loading a serialized object), MFC
needs to be able to create an object of the type serialized (see CArchive::ReadObject()).
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
How can i access PS/2 ,for ex capturing datas of mouse : will it require upper-level filters to PS/2 mouse device drivers or can i do it via user-mode with IOCTLs or perhaps ReadFile/WriteFile ?
Thank you very much
|
|
|
|
|
i don't think u can use use readfile or writefile. you need to write drivers..
If u can Dream... U can do it
|
|
|
|
|
What's wrong with WM_MOUSEMOVE? Then it won't matter what mouse is plugged in. Or are you a PS/2 chipset manufacturer, and damn these ^$&^%£* USB people?
If you're writing games, then you could look at DirectInput too.
These are only valid for MS Windows, but if you not using windows, it would be helpful to let us know that in your post.
Iain.
|
|
|
|
|
What is the path and name of physical file to store registry ?
|
|
|
|
|
there is more than one file for the registry.. they are stored in [Windows root drive]\Windows\System32\Config\.. the files are called Components,
|
|
|
|
|
I want to create a button that will force an acton to continue as long as the button is "down." For example, I want to increment a displayed field by 1 as long as the button is down. I can increment each time the button is clicked, but can't hold it down and get multiple increments. What's the general approach to this? Thanks.
|
|
|
|
|
You can start some timers on on mouse down event ,and in the timers you can do
what ever you want.. and kill the timer on mouseup. it may work
If u can Dream... U can do it
|
|
|
|
|
One way would be to respond to the WM_LBUTTONDOWN message for the button control and go into
a modal loop until the button is released:
On WM_LBUTTONDOWN...
::SetCapture(hwnd);
MSG Msg;
memset(&Msg,0,sizeof(MSG));
while (Msg.message != WM_LBUTTONUP &&
(Msg.message != WM_MOUSEMOVE ||
(Msg.wParam & MK_LBUTTON)))
{
if (::PeekMessage(&Msg,0,0,0,PM_REMOVE))
{
::TranslateMessage(&Msg);
::DispatchMessage(&Msg);
}
}
::ReleaseCapture();
A better method would be to do it like the up-down control (spin button) does:
On WM_LBUTTONDOWN
Capture the mouse (::SetCapture())
Create a timer for the desired interval of increments (::SetTimer())
On WM_TIMER
Increment displayed field
Call ::InvalidateRect(hWnd, NULL, bErase) on displayed field control
Call ::UpdateWindow(hWnd) on displayed field control
On WM_LBUTTONUP
Kill the timer (::KillTimer())
Release the mouse (::ReleaseCapture())
-- modified at 21:40 Monday 25th June, 2007
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Check out CBitmapButton in WTL, that class has this feature (it's called "autofire"), so you could take the code from there.
|
|
|
|