|
Mr.Freeze wrote:
I was told I should use an edit-box control, but this seems a bit complicated... I have to implement all the serialization stuff and so on and I might not implement it in an efficent way.
There is no ready made class, and it would be counter efficient for one to exist, because it would constrain you too much. Serialisation is easy - SetWindowText and GetWindowText to pass to the CEdit and a CFile or fstream, it's only three lines of code to store or retrieve the text in question.
You also need to set the multiline property of the CEdit, or you'll only get one line of text.
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
|
|
|
|
|
Thank you Christian
|
|
|
|
|
i just got ms visual c++.net and i am trying to make the most basic program hello world. i copied the code exactly from the original and when i go to build it, there is a fatal error. it is fatal error C1010: unexpected end of file while looking for precompiled header directive. what does this mean. can anybody help me. thanks.
|
|
|
|
|
You are missing the usual
#include "stdafx.h"
as the first include directive in your cpp file.
Max.
|
|
|
|
|
but the program has iostream.h in there already. i replaced iostream with stdafx and it created about 20 errors instead of just one. im very stupid so you might have to explain this to me. thanks
|
|
|
|
|
As he said, your compiler is set to use precompiled headers, which means that every other file MUST include stdafx.h, and when it does not, the compiler complains, as it has done. You can go into the options and turn off precompiled headers, but if you don't, you need the line.
iostream.h is also wrong. It's not part of standard C++, and has been replaced with iostream. Here is a hello world that uses standard C++:
#include "stdafx.h" // if using precompiled headers
#include <iostream>
using std::cout;
int main()
{
cout << "Hello, world";
return 0;
}
Christian
<i>No offense, but I don't really want to encourage the creation of another VB developer.</i> - <b>Larry Antram 22 Oct 2002</b>
<i>Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that...</i> - <b>Shog9 04-09-2002</b>
<i>During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. </i> - <B>Alex E. - 12-Sept-2002</B>
|
|
|
|
|
ok i couldnt find how to disable the precompiler header, so i added the lines but now i am getting errors that say: Hello World error LNK2005: _main already defined in Hello World.obj and another that says Hello World fatal error LNK1169: one or more multiply defined symbols found what am i doing wrong.
|
|
|
|
|
You have more than one main() in your code. Try creating a new console application and choosing a 'hello world' application. VC will create a hello world app ( although it may put 'using namespace std', which is very bad, you should only use the bits you need, as I did in my example. It MAY also include iostream.h instead of iostream, if it does that, it won't have any namespace stuff at all ), you can replace the code with the stuff I posted and it will all be fine. Obviously, you don't need a hello world app, you want to learn, so you may like to do a 'find in files' ( in the edit menu ) and look for main, see if you can find more than one. If not, your main is in a header which is being included elsewhere. It sounds messy enough that I would start afresh though.
What book are you using ?
P.S. if you create an account on CP, you'll actually get my responses via email, which means you'll know they happened, and have them to refer to, even offline.
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.
I found weird problem with tooltips. Help needed.
Here it is:
I added tooltips to my TreeView in my MDI Doc/View application. I didn't use TVS_INFOTIP tree style because such tooltips are hardly customizable. Insead, I enabled tooltpis for my treeview window (with EnableToolTips() method called during tree creation time), overrode OnToolHitTest and handled TTN_NEEDTEXTW/TTN_NEEDTEXTA messages (following codeguru/codeproject/msdn examples) - everything is OK with the tree tooltips.
BUT:
I noticed that sometimes, when I move mouse over main toolbar of application - tooltip for the toolbar button (file new/file open etc.) is not displayed!
My investigation proved that it's the EnableToolTips method's fault (I'm pretty sure of it).
Overriding OnToolHitTest or way of handling TTN_NEEDTEXTW/TTN_NEEDTEXTA messages has nothing to do with it.
I wrote simple MDI aplication that has only one view and does nothing except calling EnableToolTips() - in such application the same occurs. Tooltips for toolbar buttons sometimes are not displayed. When I remove EnableToolTips() call - everything backs to normal.
I even called EnableToolTips(FALSE) for treeview each time the mouse leaves treeview area - but it didn't help. Once EnableToolTips() is called during creation time of treeview, the problem with toolbar's tooltips appears and cannot be dealed with any subsequent (*after* creation of the tree) EnableToolTips(FALSE) call.
How may I cause the toolbar tooltips to be displayed always when they're supposed to?
(I'm afraid creating own toolbars may not help)
Thanks for any help.
|
|
|
|
|
If i'm using the CDockContext, how can i take a picture of the bar that's using this, i want to know this to try to make a code similar so the one in OXP.
|
|
|
|
|
Hi folks
Just a simple question I reckon..
I am doing a couple of easy C++ programs from books. Whereas before in VC++ 6.0 I used to get a console which displayed my program output and 'Press any
key to continue', I find that the same code in VS.NET flashes a console up
and it disappears instantaneously. I've gotten round this by putting something like
int abc;<br />
cin >> abc;
at the end of a main() before I return, but I was wondering if there was a
project setting I can use to bring back the 'Press any key' thingy.
Thanks for any help..
J
|
|
|
|
|
Im using a listbox to display read-only data, i.e. like a history box, or something like the "output" toolbar/window at the bottom of the standard VC++ interface(although you can click those items). Normally, as every item is added to a listbox, its appears below the previous one. Is there any way to make the most recent item appear first on the list box? This format seems preferable for something like a history/process box which im using to watch exactly what the program is doing since i make it send a string to the list box when a new function is performed. Any ideas?
Cheers,
Ayush
|
|
|
|
|
Use CListBox::InsertString (0, _T("Some text")); .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi all
I want an application , which can trace the Email origin ,ie from where the Email actualy coming frm(The Details abt the ISP,IP address etc..),Is here any articles discussing about that..? or any Idea abt how it is possible.
Thank You
Mad Coding.
|
|
|
|
|
i have some different status icons for every item in a list. i wish that i can change these icons in each item dynamically.
now it's very strange because my code works well under Win32 Debug's build but not for Win32 Release's, under Win32 Release's build the icons cannot be updated!
below are my current implementation, wish someone can help me to find out the problem. thanks a millions in advance!
-----------------------------------------------------------------
Initializations:
-----------------------------------------------------------------
CListCtrl lsclMyList;
CImageList imgls4MyList;
HICON hIcon0, hIcon1;
imgls4MyList.Create(16, 16, ILC_COLOR16 | ILC_MASK, 2, 1 );
hIcon0 = reinterpret_cast<hicon>(
::LoadImage ( AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON0),
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR ));
hIcon1 = reinterpret_cast<hicon>(
::LoadImage ( AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1),
IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR ));
imgls4MyList.Add ( hIcon0 );
imgls4MyList.Add ( hIcon1 );
lsclMyList.SetImageList ( &imgls4MyList, LVSIL_SMALL );
-----------------------------------------------------------------
1st Time Insert Item:
-----------------------------------------------------------------
LVITEM lvItem;
lvItem.mask = LVIF_TEXT | LVIF_IMAGE;
lvItem.iItem = 0;
lvItem.iImage = 0;
......// other text info
lsclMyList.InsertItem(&lvItem);
-----------------------------------------------------------------
Update Item's Icon:
-----------------------------------------------------------------
LVITEM lvItem;
lvItem.mask = LVIF_IMAGE;
lvItem.iItem = 0;
lvItem.iImage = 1;
lsclMyList.SetItem(&lvItem);
anyone knows why? i don't know where's the problem because it's working under Win32 Debug's build, there it can update the icon as i wanted. but it's so odd that when i build it for Win32 Release, the icon never changed!
programming+soccer = my current life
|
|
|
|
|
try this:
ZeroMemory(&lvItem, sizeof (LV_ITEM));
before setting your members.
in debug mode, those structs are probably being initialized to zeros. but in release mode they just have some random garbage in them.
-c
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
Thanks a lot, Chris! it's working now with ur solution!
programming+soccer = my current life
|
|
|
|
|
IIRC it's the iSubItem member not initialized. However, it's always good idea to Null Windows structs before filling them (unless you're very very tight with speed).
Curiously, the struct will no be initialized to 0 in debug mode, but to some other bit mask (I think it's 0xCC).
Global structures will be null'ed in debug and release builds
Auch den Schatten will ich lieben weil ich manchmal lieber frier' Rosenstolz [sighist]
|
|
|
|
|
Thanks a lot, !
i just tried without null the whole structure but only set the iSubItem to 0, it's also working!
programming+soccer = my current life
|
|
|
|
|
for (; !Free; ) ;<br />
Free = FALSE;<br />
<br />
what does the for loop means! I only see for(; ; ) not the above.
Thanks
|
|
|
|
|
it is the same as while(!Free)
for (initialize ; test ; increment)
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
As Chris pointed out, this is equivalent to
while(!Free); This makes little sense except in a multithreaded context where you're expecting some other thread to release a resource marked by Free . In fact, the snippet looks like a (very badly behaved) simulacre of EnterCriticalSection .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Watch that line! You've got a ; (semicolon) right after. You'll be in an endless loop, and Free will never get set to FALSE :
while (TRUE == Free)
{
Free = FALSE;
}
Seems redundant, but I explicitly test for TRUE because who knows what magic numbers (#define d) mean.
-- ian
http://www.ian-space.com/
|
|
|
|
|
My dialog project include a Strmbasd.lib file,
When I build it,5 LNK2005 errors appear:
strmbasd.lib(wxutil.obj) : error LNK2005: "public: __thiscall CCritSec::CCritSec(void)" (??0CCritSec@@QAE@XZ) already defined in TestDlg.obj
In the lib file the following class was defined:
CCritSec::CCritSec() <br />
{<br />
.......<br />
}<br />
<br />
CCritSec::~CCritSec() <br />
{<br />
.......<br />
}<br />
<br />
void CCritSec::Lock() <br />
{<br />
.......<br />
}<br />
<br />
void CCritSec::Unlock() <br />
{<br />
.......<br />
}
In my project the following class was defined
class CMemStream : public CAsyncStream <br />
{<br />
public:<br />
.......<br />
void Lock()<br />
{<br />
.....<br />
}<br />
void Unlock()<br />
{<br />
......<br />
}<br />
.......<br />
<br />
};
How to solve the problem?
|
|
|
|
|