|
When you switch from debig to release mode, rather than inherit settings from the debug mode, (even such no brainers as /subsystem:XXXXXXX) it starts from some dumb defaults which can have nothing do to with your debug mode program.
I had to change from /subsystem:windows to /subsystem console. The really weird thing (and for this I blame Microsoft) is that I had no WinMain(), only a main().
With /subsystem:windows I should have gotten a warning at the least. Now, even so, I'd expect my program to crash (or nto even compile) because there was no WinMain, BUT SOME HOW ONE GOT SUPPLIED TO IT. I accidentaly I ran it on my PC (remember it's a service, it's supposed to be started that way, plus I'm running Win98, which doesn't have full NT-Services) and it put me into a WinMain. Where I came from, I don't know... then I remembered to check the subsystem.
Many thanks to all you who tried to help!
|
|
|
|
|
Jason Hihn wrote:
because there was no WinMain, BUT SOME HOW ONE GOT SUPPLIED TO IT
MFC supplies one. Are you using MFC ?
Concussus surgo.
When struck I rise.
|
|
|
|
|
Jason Hihn wrote:
BUT SOME HOW ONE GOT SUPPLIED TO IT. I accidentaly I ran it on my PC (remember it's a service, it's supposed to be started that way, plus I'm running Win98, which doesn't have full NT-Services) and it put me into a WinMain. Where I came from, I don't know... then I remembered to check the subsystem.
AFAIS from your original post, your app is linked against MFC42.dll. Are you sure you are not using MFC?
I only ask, because it sound quite suitable to me, that MFC42.dll contains your "mysterious WinMain()".
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Is it possible to get the main window which associated with an
instance handle (HINSTANCE)? Or there's no such association?
Any help will be personally blessed!
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
I'm having a strange problem with the STL map.find(). I have a function which I search for an item's existance with a find() before inserting. If I don't find it, I insert it. Trouble is, when an item already exists in the map, both the find() and count() never report it. Also, the insert() lets me add a duplicate key. Below find declarations, code, and debug output.
// declarations
typedef struct ImportDataType
{
CString Item;
CString Value;
char Type;
long ReplicationID;
} ImportDataType;
typedef vector<importdatatype> dataVector;
typedef map<const char="" *,="" datavector=""> importData;
map<const char="" *,="" dataimportdata::datavector="">::const_iterator mapIter;
int i = dataMap.count(m_currentEID);
int j = dataMap.size();
TRACE ("\nIn AddDataItem, b4 map.insert(), size of Map = %d\n",j);
TRACE ("Number of items in the Map with key of %s = %d\n",m_currentEID,i);
mapIter = dataMap.find(m_currentEID);
if (mapIter != dataMap.end())
TRACE ("B4 insert, key found in map!\n");
else
TRACE ("B4 insert, key not found in map!\n");
for (mapIter = dataMap.begin();
mapIter != dataMap.end(); mapIter++)
{
TRACE ("Key from Map = %s\n", (*mapIter).first);
}
dataMap.insert(make_pair(m_currentEID, dataVector));
mapIter = dataMap.find(m_currentEID);
if (mapIter != dataMap.end())
TRACE ("After insert, found key in map!\n");
else
TRACE ("After insert, key not found in map!\n");
i = dataMap.count(m_currentEID);
j = dataMap.size();
TRACE ("\nIn AddDataItem, after map.insert(), size of Map = %d\n",j);
TRACE ("Number of items in the Map with key of %s = %d\n",m_currentEID,i);
for (mapIter = dataMap.begin();
mapIter != dataMap.end(); mapIter++)
{
TRACE ("Key from Map = %s\n", (*mapIter).first);
}
The partial output from running this shows the problem. Note the key values are being printed before the insert is done. The key 6748 does exist, but the map.count() and map.find() are not reporting it. Note in the last dump of the map keys that 6748 is there twice! What am I doing wrong?
In AddDataItem, b4 map.insert(), size of Map = 3
Number of items in the Map with key of 982000006006748 = 0
B4 insert, key not found in map!
Key from Map = 982000006003798
Key from Map = 982000007172537
Key from Map = 982000006006748
After insert, found key in map!
In AddDataItem, after map.insert(), size of Map = 4
Number of items in the Map with key of 982000006006748 = 1
Key from Map = 982000006003798
Key from Map = 982000007172537
Key from Map = 982000006006748
Key from Map = 982000006006748
Any ideas are appreciated as to why this does not work!
Thanks in advance,
Bob
|
|
|
|
|
There is something wrong with your code. How do you sort your items? You have to provide a < operator so the map can insert and lookup your items. And also, please format your code and change < and > with < and > so we can see your code better.
Best regards,
Alexandru Savescu
|
|
|
|
|
Alex,
Thanks for your response, sorry, I don't know how to format my code for the post, can you please tell me how? Since I don't provide a sorting criterion when I define my map, it should use the default less <>? I don't really understand the sorting criterion very well. I can see my items don't appear to be sorted. All I want to do is insert items and find items. How should I specify it?
thanks,
Bob
|
|
|
|
|
Use the <pre> tags. You can use them on the formatting bar just above the smileys. Also you can preview the messge before it gets posted.
In a map items will be sorted by key. If you use int as keys then you need not provide a < operator. But if your are using some structs then you definitely must give a comparison method.
Best regards,
Alexandru Savescu
|
|
|
|
|
I am using a key of const char *, the data is struct. How would I specify a comparison method for char *?
thanks,
Bob
|
|
|
|
|
Taking a closer look the HTML source page I found this
typedef map<const char *, dataVector> importData;
So you are using some const char* as string. Using less on them will compare pointers and of course that your map will not look as you expect. You must compare them with strcmp . Or, easier use CString as key. It has a < operator defined that does good job.
Best regards,
Alexandru Savescu
|
|
|
|
|
Alex,
Making the key a CString worked!!! Thank you very much for your help!
Bob
|
|
|
|
|
Of course it did, I just explained the reason.
If you want to use const char* (maybe for portability) then here is an exameple from the SGI documentation
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
int main()
{
map <const char*, int, ltstr> mymap;
}
Best regards,
Alexandru Savescu
|
|
|
|
|
I need make a library of 16 bits in vc++. I don`t know the statements to use.
Thank in advances
|
|
|
|
|
I think C++ 1.5 was the last to support 16 bits. They still give it as part of some of the MSDN subscriptions.
Ain't nobody ever told you : There ain't no sanity clause .Groucho Marks
|
|
|
|
|
Hi friends,
How to know what are the dlls my program is using if I am creating a program in MFC? because,when I am trying to run this program on different platforms (98 or NT) I am getting different type of errors saying particular dll is missing. Why this is happening?
Thanks
Satya
|
|
|
|
|
hi,
Use Dependency Walker which comes with MS Visual Studio Tools!
Rgds,
Sharad Ganesh
|
|
|
|
|
Thanks sharad I got it.
regards
Satya
|
|
|
|
|
If I call DeleteAllItems() then rebuild the tree by adding new nodes , I subsequently get an error stating that a memory location was changed after it was deleted . Any ideas ?
Ain't nobody ever told you : There ain't no sanity clause .Groucho Marks
|
|
|
|
|
|
It throws an exception saying that heap memory has been changed after it was freed. I am not doing it , presumably the mfc framework is. Basically I have a simple dialog with a tree control . In response to various context menus I change the contents of the tree control. I do this by calling deleteAllItems() and then adding new items by pulling records from a table . When the dialog closes it is overwriting bits of the memory that where assosiated with the items I deleted .Hence the exception. I have worked around it now , but I must still be missing something obvious ?
Ain't nobody ever told you : There ain't no sanity clause .Groucho Marks
|
|
|
|
|
Andrew Torrance wrote:
but I must still be missing something obvious ?
More than likely, but we won't be able to tell without seeing the code. We're not mind-readers ya' know.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
I draw some text on CView as shown below. How can I be able to "copy and paste" it ?
void ClassDerivedFromCView::OnDraw(CDC* pDC)
{
CFinalReport5Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->TextOut(20, 20, "sample text output to be copy-and-pasted");
}
rsg_dj
|
|
|
|
|
easy way: use CEditView
very hard way: use any other CView
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
I tried to use the CEditView but problem is I cannot break line.
eg
SetWindowText( "this is first line and \n this is second line");
Everything appears in single line, against my wish. Please help
|
|
|
|
|