|
I see exactly what your trying to do, pull the old image list and destroy it.. for some reason I can't do a HIMAGELIST blah = m_wndFormatBar(...) it says cant convert from a hImage to a long.. (or something like that) I just tried a few things real quick last night but didnt have time to do any further testing..
Thanks for the idea, I'm sure I'll get it figured out.
|
|
|
|
|
Sorry, I never actually built the code. You'll need to do a cast.
HIMAGELIST blah = (HIMAGELIST)m_wndFormatBar.SendMessage( TB_GETIMAGELIST, blah, blah );
Chris Richardson
|
|
|
|
|
I think from memory that imageList.Add makes a copy, in which case your bitmap.Detach is a memory leak.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Hi Gang,
Here's what I've got. I'm working in a doc/view architecture where I've got a tree control sitting on my left side of the screen. I don't have any problems with the line creation. (I'm just doing a simple paint style program, I've got an array of lines, it redraws each line as needed). What I'd like to do is to be able to have some sort of tree representation on the left that would list items like "Line","Text", etc.
What I can't figure out is how I let a tree-control know it needs to add elements to it's list.
I've got the tree control in a docking control bar on the left side.
As a user constructs a line, I know it's end points
Save off line info to array.
<missing step="" here=""> Insert item into the tree control so the user can reselect this specific line later on.
Later on, I'll want to respond to the tree control. As a user selects a line "Designator" in the tree control, I'll remove the line from my array and repaint the view.
Not if it weren't for that one missing step of how I tell the tree-control to add an entry......
Thanks for any help.
Sorry if this seems a little *rambly*.
I'm using VC.Net (only because I wanted to play with it anyways) on a WinXP/Pro box.
Thanks,
Nick
|
|
|
|
|
I suppose the "normal" way to do this would be to keep a pointer to a new Line object (or better, a DrawingObject object, which would be the base class of Line and Text) in your document class, then when the user creates a new line, call UpdateAllViews with lHint as some unique value out of some enum like NEW_ITEM_FOR_TREE_VIEW, then in your TreeView class, you can have an OnUpdate handler which would check lHint for NEW_ITEM_FOR_TREE_VIEW, and if it detected that, it would get the new object from the document. It's not as complex as I may have made it sound, but my brain is fried. If you have any questions, feel free to ask away!
Chris Richardson
|
|
|
|
|
I want to use CStringEx object.But I do not know how to load whole file to CStringEx object. If you know how to do that please tell me. Thank you.
|
|
|
|
|
If you are willing to fill a CString instance with the content of a file, you may use the CStdioFile class, and a simple while(!eof()){ += .ReadString() } .
How low can you go ? (MS rant)
|
|
|
|
|
For an integer I have:
bool IsNumber( LPCTSTR pszText )
{
ASSERT_VALID_STRING( pszText );
for( int i = 0; i < lstrlen( pszText ); i++ )
if( !_istdigit( pszText[ i ] ) )
return false;
return true;
}
However I need a routine to check if its a float. IsDigit returns false at the decimal point....I need to write a IsFloat( LPCTSTR pszText ) . How do I do this?
Appreciate your help,
ns
|
|
|
|
|
You need to check your string it there is a dot within two numbers.
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Can you not just go under the assumption that if a period exists in the string then it's safe to say it's a floating point...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Only if you can guarantee that the program isn't used outside English-speaking part of the world. Out here some of us want to use comma as the decimal separator.
|
|
|
|
|
Pardon my English ignorance..
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Was considering that but I had quantities like 123.456:78 as well. So I thought that it would have to have "." but no ":" to be a float. Christians given me a good snippet and I'm going to doctor it up to handle my weird "numbers"...
Appreciate your help,
ns
|
|
|
|
|
As is often said, if you expressed what you want in plain english, it would be obvious to you.
bool IsFloat( LPCTSTR pszText )
{
ASSERT_VALID_STRING( pszText );
const int nLen = lstrlen( pszText );
int nDots = 0;
for( int i = 0; i < nLen ); i++ )
{
if (pszText[i] == '.')
++ nDots;
else if( !_istdigit( pszText[ i ] ))
return false;
}
return (nDots < 2);
}
That will return true for int and float, make it return (nDots == 1) to be true for float only.
Note, I did this in CP, it is untested, but the idea is sound.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I really wouldnt have stumbled on it in a million years..... . Many thanks!
Appreciate your help,
ns
|
|
|
|
|
Gosh! Works like magic! Did what I was trying to like a charm! Really made me think, and appreciate the cool technique...
Thanks!
ns
|
|
|
|
|
CMyView::OnChar(...)
{
PostThreadMessage(id,msg,0,0);
}
when i type with less than 130ms time intervals between keystrokes a deadlock results in the app's main thread.Any help would be greatly appreciated.
|
|
|
|
|
Are you accessing MFC window classes from the thread's message loop?
MFC Window classes + threading = recipe for disaster.
You are better off doing all your window message handling in the main app thread and delegating any time-consuming work to worker threads to make the application respond better.
I have had my share of problems trying to update MFC frame windows and views from threads. I later used userdefined messages to the window for all my events from the thread, so that all GUI functions like updating views etc were done in the main thread.
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Sorry to bother you guys with beginner questions, but I need help with the ListView control. I am creating an about dialog box and want to list all of the files installed (like Outlook Express). I have had a little success with it, but I am having trouble getting items to appear in the second or third column. The items only show up on the first column. How do I tell the program to place the text in specific columns (I am using MFC)?
-- Steve
|
|
|
|
|
On CP there is a CSortListCtrl which simplifies this task ten fold and it allows you to click on the header columns to sort ascending or descending...
Check it out...
I'm not totally familiar with CListCtrl , but I reckon you probably get items in the second, thrid columns by specifiying that the main items has child sub-items....
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
LVITEM lvi;
//fist item
lvi.mask = LVIF_TEXT;
lvi.iItem = 0; // First column
lvi.iSubItem = 0; // Frist item
lvi.pszText = (LPTSTR)(LPCSTR)("Item 1");
// Now insert the item
m_myList.InsertItem(&lvi);
// Now set the text for the 2nd, 3rd ,4th items they will go in row 0 "which is the first row"
m_myList.SetItemText(0,1,"Item 2");
m_myList.SetItemText(0,2,"Item 3");
m_myList.SetItemText(0,3,"Item 4");
|
|
|
|
|
Thanks a lot. That solved my problem. I just converted from Win32 programming, and ListView is a little different. For instance, the variable LVITEM is LV_ITEM in Win32. Thanks for helping me solve my problem.
-- Steve
|
|
|
|
|
can anyway recommend any mp3 encoders/decoders C/C++ libraries (must be minimum 128KBps quality) in order to stream LIVE audio over a network? I'm trying to create an application which will be like a video conferencing app but audio only.it will allow a minimum of 3 musicians to hear the other musicians playing live and also record the session.
cheers
|
|
|
|
|
MS DirectShow (part of DirectX) could provide both the application logic, and the necessary codec stuff. For instance, you have an input filter with an associated moniker to receive a stream from the network. More info in the SDK.
How low can you go ? (MS rant)
|
|
|
|
|
I cant check it out right now, but what will atoi(123.567) return? I'm hoping its 123...?
Appreciate your help,
ns
|
|
|
|