|
Well, on most systems, a char is a signed number from -128 to 127. Considering that the characters you are trying to test are in range of 0-127, you shouldn't be having a problem.
As far as the prompt for _CTYPE.C, you must not have installed the CRT source when you installed the compiler (God I LOOOOOVE having the CRT source.)
What are you doing wrong? I don't know. What is the value of chrSymb when it is failing?
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Hi,
I'm working on a multi-view application and I'm trying to change the mouse cursor when it is moved over one of the views.
I've got the following code in the view:
BOOL CTheView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
::SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(m_mouseCursor)));
return TRUE; //Handled
}
I'm doing it this way since I've disabled the class cursor with:
::SetClassLong(this->GetSafeHwnd(), GCL_HCURSOR, NULL);
and initialised the m_mouseCursor attribute with the appropriate system cursor type. [This appears to work since a later attempt to GetClassLong(GCL_HCURSOR) returns NULL.]
However, when I drag the mouse over the view, I get the required cursor flickering with the standard mouse cursor. When the mouse stops moving, the standard mouse cursor is the one displayed. This eliminates the cause being an incorrect cursor id, since the correct cursor actually appears, but overwritten shortly after.
I suspect the problem to be due to the fact that I have a number of views in my application, but the cause is unfortunately not clear.
If anyone can shed any light on this, your help will be much appreciated.
|
|
|
|
|
My first guess is you're calling the global scope SetCursor function and you need to call the one that is a member of your window. Remove the :: and see what happens.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Thanks Christian,
It wasnt that. It turned out to be a silly error. Another place in the code was calling BeginWaitCursor() EndWaitCursor(). Turns out EndWaitCursor() simply resets the cursor to the standard arrow cursor, not to the previous cursor as would be logical.
|
|
|
|
|
I find the step through function useless in Visual C++ because it always takes you into the machine code -- I find this very cool, but I can't follow the execution of my program because it takes me through so many details. In visual basic I step through the code all the time, because I can watch what happens. Is there any way to set up my debugger so it just steps through _my_ code and doesn't go into all the library files?
I would be very happy if you can help me . . .
tim;)
---------------------------------------
Tim Booher
|
|
|
|
|
It steps into the library files where the source is not available ( such as API calls ), just use shift-F11 to step out again when it does that.
The excellent 'Debugging Windows' book by John Robbins covers enough asm to help you start finding the asm output useful. So they tell me, I never had time to make head nor tails of it
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
Thanks -- that is a lot more helpful, but what do you mean by (the source is not available) if the source were not available -- then how could the debugger step into the the source.
cheers,
Tim
---------------------------------------
Tim Booher
|
|
|
|
|
The C++ source for, for example, ::EnumWindows is not given to us, so it steps into the actual compiler generated code, which is obviously going to be there, otherwise you couldn't run it. The source for MFC is installed with VC, which is why you can step into the operations of MFC classes.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
I personally use F-10 to step over my code while watching variables in watch and heap or stack in memory view.
F-10 mostly avoids the whole assembly language dump which will only happen when you encounter functions with no associated debug info. You usually get Can't trace into system dll's if you try to "step in to" an API function like
::CreateWindow(). You can if you like step through the MFC wrapper classes and i believe crt. The visual C++ debugger is more complex than VB, but complexity means power!!!
Maybe your seeing assembly because you viewing your code in disassembly. Next time try closing the dissassembly window and click the yellow arrow to see what line your on...
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Thanks so much for all your help -- I learned a ton about debugging today and blew through a program that would have kept me up all night last week.
Now I reckon I'll have to find someone else's question and give them a hand. thanks,
tim
|
|
|
|
|
How to retrieve the name of the domain under which a NT process is running?
Chen Venkataraman
|
|
|
|
|
Seems like <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/ntlmapi2_07zj.asp">NetWkstaUserGetInfo</a> is what you're looking for.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks.
Chen Venkataraman
|
|
|
|
|
I'm working on a map editor for my game and I've ran into some problem. To give you an idea of what's it supposed to do, think of the old game mine-field. Now my program is supposed to put an unlimited number of those mine-objects manually. The number of the 'mines' could range between 0 and 384. The 'mine' is derived from a class.
I solved the problem by defining an array with the maximum of 384 mine-objects, each representing a place in the map. And when I want to actually put the mine I just "activate" it. It works, but it's a waste of a lot of memory because it's 384 mine-objects, 384 prize-objects etc etc. You get the idea.
How can I implement a better way to define new objects at run time? I figured memory allocation would help but how does it work with classes? I only used it for simple arrays not objects that contain various types of variables.
Thanks in advance,
Isaac Sasson,
Small time programmer - complainer at large.
Sonork ID 100.13704
|
|
|
|
|
You can use STL vector , which works pretty much like the arrays you're used to, with some extra capabilities, like the ability to grow on demand. If your mine objects are instances of a class called (for instance) CMine , then you declare your vector like this:
std::vector<CMine> vectorMines; Initially, a vector is empty. You can populate it with
vectorMines.push_back(CMine(...)); Elements of a vector are accessed in a way similar to a built-in array:
for(size_t i=0;i<vectorMines.size();++i)
{
vectorMines[i].draw();
} STL comes wiht other containers (list s, map s) offering different features and trade-offs (random access vs. random erasing, for instance). Look for some STL tutorial on the net and start enjoying this great library.
Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Functionally, there is little difference between:
main ()
{
CMine theMines [384];
}
and
main ()
{
CMine *ptheMines = new CMine [theNumberINeed];
... do stuff ...
delete [] ptheMines;
}
Don't sweat creating an array of the specific number of mines you need after you determine the count.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
The problem is I don't know the number of "mines" nor does the user. It's desgined that way you just add mines whenever and wherever you like at run time, it doesn't ask you for the number of "mines" you're going to use.
I used your solution for the game itself when the number is set after reading the level data from a file.
The editor however is a bit different.
Thanks anyway.
Isaac Sasson,
Small time programmer - complainer at large.
Sonork ID 100.13704
|
|
|
|
|
Hello friends !
How are you ?
I need a small help . Please !
Well, I see that CFile::Open with CFile::modeCreate|CFile::modeWrite
When I want to write into the file if it exist and if not to create it works excellent in win98
but on win2000 and XP it success only to create the file if it was not ,and when the file (.dat) already exist it doesn't success to perform modeWrite and should have first to do : CFile::remove()
my question :
1. Why ?
2. How could to do it at the best and elegant way ?
3. Are there a function to know if a specific file exist or not ? which ?
thanks in advance
|
|
|
|
|
mimi wrote:
Are there a function to know if a specific file exist or not ? which ?
Check:CFileFind
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
I think I found the answer to my second question
perhaps I need to add CFile::modeNoTruncate
|
|
|
|
|
Hello people.
I'm trying to get a CFormView derived class inside of a dialog. Why? well, i want a small area of my dialog to be kind of a sub dialog, with dynamically created controls in it. CFormView is a nice way to go, cos then i get scroll functionality on this little pane.
Anyway. Trying to add the view like this:
CRect rect(10, 10, 200, 200);
CRuntimeClass* pClass = RUNTIME_CLASS(CMyFormView);
pView = (CMyFormView*)pClass->CreateObject();
pView->Create(NULL, NULL, WS_CHILD, rect, this, AFX_IDW_PANE_FIRST, NULL);
pView->MoveWindow(rect);
pView->ShowWindow(SW_SHOW);
This doesn't work. The compiler generates an error on the pView->Create() line. This is because the Create() member (which comes from the base class) is protected:. but I don't understand why it's protected! it's not in CView, and not in CScrollView.
So what I tried next, was adding a virtual function, Create() to the CMyFormView class. the supplied virtual function calls the base class implementation, using the parameters passed in. ie:
BOOL CMyFormView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
This seemed a good idea, because the virtual function is allowed to call the protected base class member. However, running the code causes an assert, in the base class create... ie CFormView::Create()...
if (!_AfxCheckDialogTemplate(m_lpszTemplateName, TRUE))
{
ASSERT(FALSE);
Something's wrong with the dialog template name. But I thought this was handled by the framework on my behalf? I specified a dialog resource when I created the class, and the enum IDD in the class declaration of my dirived class reflects this. Any clues as to how to get a working CFormView inside a dialog???
Your help will earn you a beer!!!
Thanks
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Immediately after posting that last message, I realised i'd used a regular dialog box template, not a IDD_FORMVIEW type template.
Oh dear, i think it's time to get some sleep.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I have problem with style report in the concrete with resizeing columns. I wrote code to autoresize(as resizeing column in Outlook) column but problem is while users changeing width of App (for example CListView in SDI app). During resizeing (because width of column is not changeing at once) users can see horz. scrollbar. Present MS-Outlook - here is same case.
Can I set width of column at once ? Currently I useing function SetItem().
My Code :
HRESULT CDodomuHeaderCtrl::OnLayout(WPARAM wparam,LPARAM lparam){
if (!m_bNowResizeing){
AutoSizeItems();
LPHDLAYOUT lay = (LPHDLAYOUT)lparam;
HRESULT lResult = CHeaderCtrl::DefWindowProc(HDM_LAYOUT, 0, lparam);
return lResult;
}
else {
return NULL;
}
}
void AutoSizeItem(){
... compute new width
m_bNowResizeing = true;
for(....){ // (remark 1)
HDITEM item;
... fill struct
SetItem(i,&item);
}
m_bNowResizeing = false;
}
-----
remark 1. :
Here is greatest problem : If users decrease width of ListCtrl will in moment width of all column >> ( ) then client area and Windows (CListCtrl) show horz. scrollbar.
Please ... Can you help me ?
Thank VERY MUCH !!!!
Wizard
|
|
|
|
|
Haven't tried it myself, but maybe you can use WM_SETREDRAW to disable automatic redrawing while the resizing is in progress:
void AutoSizeItem(){
... compute new width
SendMessage(WM_SETREDRAW,(WPARAM)FALSE);
for(....){
HDITEM item;
... fill struct
SetItem(i,&item);
}
SendMessage(WM_SETREDRAW,(WPARAM)TRUE);
} Let us know if that worked! Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
))
Thank you for !!!
Wiizi
|
|
|
|
|