|
When you use the >> operator when reading a file I noticed spipws is there by default. I open the file using File.open("file.txt"). How can I modify this so I can include the whitespace?
|
|
|
|
|
unsetf( ios::skipws )
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
hi i want to help me to release the graphical recources and the Device context in the code below
CFont cf;<br />
cf.CreateFont(16,0,0,0,FW_BOLD|FW_EXTRALIGHT,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Arial");<br />
<br />
CBitmap b;<br />
b.LoadBitmap(IDB_BITMAP1);<br />
<br />
BITMAP bm;<br />
b.GetObject(sizeof(BITMAP),&bm);<br />
<br />
CClientDC h(cw[n]);<br />
<br />
CDC *dc=new CDC;<br />
dc->CreateCompatibleDC(&h);<br />
dc->SelectObject(&b);<br />
<br />
h.SetTextColor(RGB(10,50,220));<br />
h.SelectObject(cf);<br />
<br />
<br />
h.BitBlt(0,0,bm.bmWidth,bm.bmHeight,dc,0,0,SRCAND);<br />
dc->DrawText(Int2CString(cw_key[n]),CRect(2,5,25,25),DT_CENTER);<br />
h.BitBlt(0,0,bm.bmWidth,bm.bmHeight,dc,0,0,SRCAND);<br />
<br />
i write this below code to release them but it seems that i forget something to release .because program will become very Slow after 1 or 2 mintue.
cf.DeleteObject();<br />
b.DeleteObject();<br />
dc->DeleteDC();
when i write : h.DeleteDC(); an error will Occure --> Unhandled exception at 0x77f767cd in MASTER.exe.
i dunno why.
thanks for your help
|
|
|
|
|
HellShrimp4free wrote:
when i write : h.DeleteDC(); an error will Occure
Don't do that. The destructor of CClientDC will take care of it.
What you however should do is either
delete dc;
or put that CDC on the stack, not on the heap.
|
|
|
|
|
I have written a program than spans six cpp file all of which share class information which is located in one header file. I am having a problem organizing my code concerning the global class objects. Each cpp file has it's own header file and depeding on the source code file some header files are nested etc...I would like to organize the program better and do not want to put extern class... at the beginning of each source file. How can I get around this problem? #ifndef-#endif seems could be the way to go but I can't quite get it without link errors. If someone could help out I would be greatful. Thanks.
|
|
|
|
|
Put all the extern statements into a .h file of their own and have all the .cpp file include this file. Only one place needs to be updated for all .cpp files to be updated.
Roger Allen
Sonork 100.10016
This is a multiple choice question, choose wisely
Why did the hedgehog cross the road?
A: To show he had guts?
B: To see his flat mate?
|
|
|
|
|
|
Hello,
yesterday I've found a nice manual on memory addresses. A part:
--------K-M00400017--------------------------
MEM 0040h:0017h - KEYBOARD - STATUS FLAGS 1
Size: BYTE
SeeAlso: MEM 0040h:0018h,INT 16/AH=02h,MEM 0040h:0096h
Bitfields for keyboard status flags 1:
Bit(s) Description (Table M0010)
7 INSert active
6 Caps Lock active
5 Num Lock active
4 Scroll Lock active
3 either Alt pressed
2 either Ctrl pressed
1 Left Shift pressed
0 Right Shift pressed
SeeAlso: #M0011,#00587
Now my question: How can I read this byte?
I tried this code:
unsigned char uTemp;
unsigned char *pNull = NULL;
uTemp = pNull[0x00400017];
char szTemp[32];
sprintf(szTemp, "%02X", uTemp);
MessageBox(GetDesktopWindow(), szTemp, "clock", NULL);
But it always prints "00", zero. But numlock is on! Therefor I think i misinterpret the address.
Whats the correct memory address for pNull[] to read from? How must I convert the "0040h:0017h"?
Thank you!
-Dominik
|
|
|
|
|
This seems 16-bit addresses. You cannot happily inspect those addresses in Win32 protected mode, so I guess what you're inspecting is just a random location into the virtual memory space of the program.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
And how can I then read these 16-bit addresses?
It must be possible. Or how do other system information programs get advanced information about the BIOS (more than the 4 information strings in the registry)...?
|
|
|
|
|
Dominik Reichl wrote:
How can I read this byte?
From Win32? You can't. You needing ring0 privs (i.e. kernel-mode device driver).
But why would you want direct hardware access when GetKeyState, GetAsynchKeyState and GetKeyboardState can give you the same info?
|
|
|
|
|
I am currently developing a system information tool and there I need BIOS information (more than the 3 string values in the registry).
The keystate access was just thought as an example. There are many other, more interesting, values in this memory section.
Do you know how other system information programs get this information? For example, how do I detect, if the installed BIOS is flashable?
Thank you
-Dominik
|
|
|
|
|
I have some dialog controls inside an CFormView derived dialog and I need to clear them when the user selects New from file menu or when CDocument::OnNewDocument() is called.
How can I do this?
Thanks
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Can u be more clear..??
Is this Document and ur Fromview related ....
OnNewDocument() which view is created? or u want to show existing view...
Is this SDI or MDI....
Canu be more specific
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
You can use CDocument::UpdateAllViews to send an update message to all the views which are attached to your doc.
|
|
|
|
|
I'm trying to use multiple CFrameWnd objects in addition to my main window. CMainFrame is my main window class create by App Wizard. I later created another subclassed CFrameWnd but I want it to be a child window of CMainFrame. I've only been able to get it to work properly if I create this child window using the "new" operator.
From my basic knowledge of C++, it is best to delete objects allocated with the new operator once we're done with the object. When should I use delete in this scenario? One of my attempts was to add a pointer to my subclass (call it CMyChildFrmWnd) as a public member variable in CMainFrame (m_myChildFrmWnd). I override CMainFrame::OnDestroy() which is just a message handler and not the Destroy() function itself, and in OnDestroy() I do:
if(m_myChildFrmWnd)
{
delete(m_myChildFrmWnd);
m_myChildFrmWnd = NULL;
}
Doing this causes an Access Violation error (0xC0000005).
If I don't manually delete this pointer allocated by using the new operator, will the memory consumed be freed automatically when the program exits? Is it going to be a problem if I keep creating new instances of CMyChildFrmWnd over and over again throughout the lifetime of the program's execution? For example, every time the user clicks a button:
m_myChildFrmWnd = new CMyChildFrmWnd;
Any suggestions on how to handle this or a better way of creating multiple frame windows? I would prefer not to use MDI child windows.
|
|
|
|
|
CFrameWnd s auto delete on destroy time, so you mustn't delete them explicitly: they will clean up when the user closes them or programmatically with m_myChildFrmWnd->DestroyWindow() .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the quick reply.
|
|
|
|
|
How can I define the full path of my application(exe file) in order to check it's location in the PC every time it is started? Is there SDK or MFC function about this?
|
|
|
|
|
Use GetModuleFileName with hModule==NULL .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
i have a little problem.
my project name is MASTER. and in this project there are some class such as CMASTERView.
i defined some Public Variable in CMASTERView class(for example w1,w2,w3)
then i defined a class with this name : TREE. i do this with ADD CLASS option.
even i want to use w1 or w2 or w3 in class TREE an error occures : "w1" undeclared indentifier
what can i do if i want to use those tree variables in Class TREE ?
thnx
|
|
|
|
|
Well I really fully understand what u wanted to say..Anyway i will try to clear with what i have understood..
What is the relation between TREE class and CMasterview Class..If there no relation then that varibale will be out of scope only...
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
w1,w2,w3 are members of class MASTER, they are not global variables. You need an instance of the class MASTER containing them. Public means that you can access them from any code, not only from methods of the MASTER class.
MASTER m1,*m2;
m2 = new MASTER();
m1.w1 = 1;
m2->w1 = 2;
Pavel
Sonork 100.15206
|
|
|
|
|
I'm reimplementing a project that currently uses a ListView as the major interface. This list displays a lot of items that themselves contain lists. But to see the contained lists you currently double-click an item and a new dialog-based editor window opens.
I'd like to redo this with an "expanding listview" rather like the Macintosh version of a treeview with the little triangle widget on the left. However, both the main listview and the subitems have column headings, and of course they are completely different from each other. So I probably want to have a second header control appear when a tree is expanded, and dragging the header column sizes should only change the columns for the item or subitem entries. Then of course all of the line items have to allow single/multiple selection, cut/paste and drag/drop, both to other places in the current listview, but also to other listview windows in the same project.
I have a hunch I'm going to end up having to build this thing myself from pretty much scratch, and GUI stuff is *not* my stong point!
So does anyone have suggestions on where I can find this contol? Or more likely, suggestions on which pieces I might grab to start making this thing?
Thanks a bunch!
Loren
|
|
|
|
|
How can I find out whether a scrollbar associated with a CScrollView window is currently being shown?
|
|
|
|