|
Hi,
Here's what I need to do:
I have a tree view control that has a list of strings on it. Those strings can be updated outside of the tree view. When updated outside the tree view, I need to update their strings inside the tree view to match the newly edited strings.
So the question: Is there any way to get an item in a tree view without knowing its handle? Can't I just get it by string or something? I figured I'd just search through the tree view to find the TV_ITEM with the matching string, then update it to the new string with a TVM_SETITEM message. I think this should work just fine, if I could get the TV_ITEM in the first place, but the TVM_GETITEM message only seems to retrieve by handle.
Thanks!
KR
|
|
|
|
|
With TVM_GETITEM, you can get several items of information about the items, including the text.
Check out the TVITEM struct and the TVITEM.mask (TVIF_TEXT), TVITEM.pszText, and
TVITEM.cchTextMax members.
I believe you'll need to use TVM_GETNEXTITEM (with TVGN_ROOT, TCGN_NEXT, etc) to traverse the
tree getting the handles to pass to TVM_GETITEM.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Okies, I didn't realize I could use TVM_GETNEXTITEM to get the root tree item. Thanks a lot, this should work perfectly.
KR
|
|
|
|
|
Hello there. I hope you have a solution to my question, because is blowing my mind. I have a rich edit control and i'm getting the input to a CString using GetWindowText. Now i want to convert the string to double. I' m using atof(), but that's not my case... The value in the rich edit represents a number between 0 and 20. If i write "Hello" in the rich edit or "12.h", atof() still converts it to double, but differently the user didn't type something between 0 and 20. Even more didn't type a number at all. Is there any way to do this?
|
|
|
|
|
This is what MSDN says about atof : The function stops reading the input string at the first character that it cannot recognize as part of a number.
So its up to you to scan the string for non-numeric characters before calling atof . You could use ES_NUMBER on the rich edit control, if you only wanted the user to enter numbers - in that case a simple edit control would work.
Best wishes,
Hans
|
|
|
|
|
johnny__XP wrote: but differently the user didn't type something between 0 and 20. Even more didn't type a number at all. Is there any way to do this?
better use _tcstod
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
always use _strtod
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi guys,
I am writing a simple program that the user would like to be able to run from the command prompt. I am wondering how I pass that infromation into the main of my program. For example, if you wish to run Windows explorer from the command line you pass the command "explorer". This will launch Windows explorer and default to showing C:\. However, you can also call explorer and have it open a specific directory "explorer C:\Test\MyTest".
My question is this:
Is the second part of that simply passed as the argument to main? For example if I wanted my program to specify a string, could I have my main function accept a const char *?
I.E. void main(const char *inputString) ?
where inputString would be whatever it is that I have passed immediately after my *.exe name?
so the total call would be something like:
C:\> stringParser This Is My Test
which would hopefully pass a pointer to "This is My Test" into my main argument.
Thanks,
Joe
|
|
|
|
|
In Visual C++, you can use the version of _tmain that has command line argument parameters:
int _tmain(int argc, _TCHAR* argv[])
See main: Program Startup[^]
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: int _tmain(int argc, _TCHAR* argv[])
strange from microsoft that argv is not an array of const TCHAR*
|
|
|
|
|
toxcct wrote: strange from microsoft that argv is not an array of const TCHAR*
Yeah. I guess it stays consistent with the old days of C
There's no const in any of the prototype variations.
Beats me!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
if you somehow graduate to windows programming you can use GetCommandline api to reterive the command line
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi all,
Can any one convert this simple piece of code from C#.NET to C++(general). I am getting error while performing this. I guess i am going wrong somewhere.
private String GetFileName(String filter){
OpenFileDialog dlg = new OpenFileDialog();
dlg.Multiselect = false;
if(filter.Length > 0){ dlg.Filter = filter; }
if( dlg.ShowDialog(this) != DialogResult.Cancel){
return dlg.FileName;
}else{
return null;
}
}
private void btnImageFile_Click(object sender, System.EventArgs e) {
String fileName = GetFileName("Bitmaps (*.bmp)|*.bmp|Tagged Image File Format(*.tif)|*.tif|PNG-24(*.png)|*.png");
if(fileName != null){
txtImageFile.Text = fileName;
SetImage(fileName);
}
Thanks a lot
|
|
|
|
|
Do you want to show a dialog to user for select an image file(not multiselect because its false on your code) and draw it? You can write this code with CFileDialog
|
|
|
|
|
okay
well i can open a dialog box and select file by
OpenPictureDialog1->Title= "Open File: ";
if (OpenPictureDialog1->Execute())
bmpFileEdit->Text=OpenPictureDialog1->FileName;
return;
But i want that it should not select any file other than .bmp, .tif and .png.
So you mean i can do this via CFileDialog. Okay ill look for it, if i get any clue how to do it with this.
Thanks
|
|
|
|
|
I dont have any compiler now(but I have 3dmax program now ) but try to compile this code and see what happens?(it shows only txt files
CFileDialog m_Open_Dialog(1,0,0,OFN_EXPLORER ,"Text Files (*.txt)|*.txt||",0);
and also instead use of
use of
if(m_Open_Dialog.DoModal() == IDOK)
-----------------------------------------------
It seems previous code show a dialog to user to select image files and show filename on the a labeltext maybe and send filename to a function.
|
|
|
|
|
Something like this maybe (I've used no MFC and no STL/MFC/ATL string classes)...
bool GetFileName(LPTSTR pszBuffer, DWORD dwBufferSize, LPCTSTR pszFilter)
{
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFilter = pszFilter;
ofn.lpstrFile = pszBuffer;
ofn.nMaxFile = dwBufferSize;
ofn.Flags = OFN_EXPLORER;
return 0 != ::GetOpenFileName(&ofn);
}
...
TCHAR szFileName[MAX_PATH] = _T("");
if (GetFileName(szFileName, MAX_PATH, _T("Bitmaps (*.bmp)\0*.bmp\0Tagged Image File Format(*.tif)\0*.tif\0PNG-24(*.png)\0*.png\0\0")))
{
}
else
{
}
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi thanks a lot
But i think simple use of filter could solve this out. Well what i did now is
<br />
OpenPictureDialog1->Title= "Open File: ";<br />
OpenPictureDialog1->Filter = "Bitmap files (*.bmp)|*.BMP";<br />
if (OpenPictureDialog1->Execute())<br />
bmpFileEdit->Text=OpenPictureDialog1->FileName;<br />
return;
So this gives me only bitmap file to select. So its fine the only thing now left is function
SetImage(fileName) function i.e.
<br />
private void SetImage(String fileName){<br />
picImage.Image = new Bitmap(fileName);<br />
<br />
btnHide.Enabled = btnExtract.Enabled = true;<br />
btnSaveBitmap.Enabled = false;<br />
<br />
int index = fileName.LastIndexOf("\\")+1;<br />
if(index > 0){ fileName = fileName.Substring(index); }<br />
grpPicture.Text = "Carrier Bitmap ("+fileName+")";<br />
}
Ill try to convert this aswell. Well and yeh i said General C++ i meant no VC++. As i am using Borland. So it doesnt support the option you gave.
Can any one give me any tips as i have got this VC++ pure win32 application and C#.net application n i want to convert it to General Borland C++. I know i have to do it manually but still any good pts i should follow.
Thanks a lot for your time...
SS
|
|
|
|
|
What part didn't compile on Borland? You should be able to use Windows APIs - that's what .NET
is using under the hood. You may need to include the appropriate header files and link libraries.
For non-Unicode builds you can eliminate the "_T()" macros I used. Replace "LPCTSTR" with "const
char *", "LPSTR" with "char *", "TCHAR" with "char".
For the second part, what needs to happen? Do you load the image as a GDI+ Bitmap object?
Then format the file name into a string?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hi i have to cancel(close) the dilaog from a user defined function. how to do this?
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Simply call OnCancel from your function.
|
|
|
|
|
hmm i tried that but got crash sinc hwnd is null
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Where and how are you calling OnCancel() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can you show code snippet?
|
|
|
|
|
You could manually send a WM_CLOSE message to your dialog handle.
For instance if the handle to your dialog is:
HWND MyDialog;
SendMessage(MyDialog, WM_CLOSE, 0, 0);
KR
|
|
|
|