|
1) You have to allocate the memory where the registry functions can copy the data to. I.e. instead of declaring LPBYTE declare a byte array (BYTE arr[1024] for example), instead of LPDWORD declare DWORD and give the registry functions a pointer to it (using &).
2) The PHKEY is needed. The RegOpenKeyEx function could not modify the HKEY variable without a pointer. (Here the same: declare HKEY and give RegOpenKeyEx a pointer to it, i.e. &hkey).
3) Specify the length of your buffer. In the code above you just give the RegQueryValueEx function a length variable which you haven't initialized anywhere.
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
OK !! Now I get it... In fact, I´used the function in a very stupid way.
That's how it works now (for the forum readers ):
BYTE buff[1024];
DWORD length=1024;
DWORD dummy;
HKEY hKey;
yop=RegOpenKeyEx(HKEY_CURRENT_USER,"Environment",0,KEY_ALL_ACCESS,&hKey);
yop=RegQueryValueEx(hKey,"TSLastName",0,&dummy,buff,&length);
Thanks a lot, Dominik, a for you
~RaGE();
|
|
|
|
|
Hi,
I have constructed a generic application with the idea to use it over and over again. The problem is that this application also has a user interface that is different for different customers. The functionality is roughly the same, though.
Now I'm trying to do the following. The GUI was implemented in document/view/frame combinations which run in an MDI application. These forms were originally programmed inside the exe but now I want to disconnect them from the exe one way or the other. My idea was to put them in a COM-component and let the component register the document/view/frames in the exe.
This doesn't work though. As soon as I try to create a childframe window in the COM-component, I get messages that the main window isn't valid (HWND obviously is corrupted, which I can understand).... Is there a way to get this job done?
I've been considering the following alternatives:
* Move the GUI-classes to a MFC Extention DLL and somehow extract them from there and let the exe create the dialogs/views
* Put the GUI-classes inside a toolwindow docked inside the MDI-app. I still have problems with the parent-window pointer them, though
* Something else... Maybe use full-screen modal or modeless dialogs and create those inside a COM component....
I still prefer my first idea though, if it is technically realisable.... Can anyone help?
Structured programming vs. chaotic mind boggling
|
|
|
|
|
For a module I want to write my own stream class.
Although not identical the following example illustrates what I want to do:
suppose you have a class representing a printer:
class Printer { ...};
I want the user of this class to send data to this class using the << operator, so that any data type/class, for which << is defined on streams, e.g.
Printer myPrinter (printerName);
PrinterStream &printStr = myPrinter.getStream();
printStr << "Hello world" << 123 << std::endl;
So, how can I write my own stream class so that I can intercept the data send to printStr?
I probably need to inherit from some STL stream class, but I don't know where to start. Is this something that can be done easily, or is this almost impossible?
Another alternative (although I don't really like it) is to let my getStream() method to return a stringstream. My class then simply needs a kind of flush method to get the data from the stringstream, send it to the output where I want it and then empty the stringstream. I don't like this alternative because it exposes the fact that's a stringstream to the caller. Also I cannot add my own output manipulators (e.g. to set the font or color) to the stream.
Does anybody know a simple solution, or point me to an article that explains how to write your own stream class?
Thanks in advance.
Enjoy life, this is not a rehearsal !!!
My Articles:
- Implementing a Subject/Observer pattern with templates
- Different ways of writing class factories
- AutoRunner: a template class to automatically run start- and cleanup-code in code blocks
</
|
|
|
|
|
I would inherit from ostringstream, overloading output stream operators for your formatting classes. If the format written is binary (contains null characters) it needs special handling.
(Remember that std::endl doesn't just append a newline character. It also makes the stream call flush(). Hence, you need to consider how the flush() method should behave when using this class.)
|
|
|
|
|
Hi
I am drawing a rectangle on the screen using the following code:
void CImageControl::OnLButtonDown(UINT nFlags, CPoint point)
{
m_down = true;
pDC = new CClientDC(this);
pDC->DPtoLP(&point);
m_currentpoint = m_newpoint = point;
CStatic::OnLButtonDown(nFlags, point);
}
void CImageControl::OnLButtonUp(UINT nFlags, CPoint point)
{
if (m_draw)
{
pDC->DPtoLP(&point);
pDC->SetROP2(R2_NOTXORPEN);
pDC->Rectangle(m_currentpoint.x, m_currentpoint.y, m_newpoint.x, m_newpoint.y);
CStatic::OnLButtonUp(nFlags, point);
pDC->SelectObject(oldpen);
m_draw = false;
ReleaseDC(pDC);
}
}
void CImageControl::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_down && nFlags == MK_LBUTTON)
{
m_draw = true;
pDC->DPtoLP(&point);
oldpen = pDC->SelectObject(boxpen);
pDC->SetROP2(R2_NOTXORPEN);
pDC->Rectangle(m_currentpoint.x, m_currentpoint.y, m_newpoint.x, m_newpoint.y);
m_newpoint = point;
pDC->Rectangle(m_currentpoint.x, m_currentpoint.y, m_newpoint.x, m_newpoint.y);
}
CStatic::OnMouseMove(nFlags, point);
}
Sometimes the rectangle stays on the screen sometimes it disappears immediately.
How do I get it to stay on the screen? No resizing is done that one would think would cause the screen to be repainted.
|
|
|
|
|
Try adding a TRACE() statement to the OnPaint() and ensure it isn't being called.
It looks like you aren't deleting the CClientDC. Also if OnLButtonUp() is called an !m_draw you aren't cleaning up at all.
FranzKlein wrote:
ReleaseDC(pDC);
I can't find a Release( CDC* ). Does this do a DeleteDC(). I can't see where you are doing delete pDC either.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Is there a function to add a number to the system time?
After I retrieve the system time I want to add lets say 3 hrs to the system time.
Thanks!
|
|
|
|
|
How do you retrieve the system time (post your code) ?
~RaGE();
|
|
|
|
|
I'm using COleDateTime::GetCurrentTime();
Of course, there are many ways to retrieve the system time. If it makes life much easier I can easily use a different function call.
Thanks!
|
|
|
|
|
GetLocalTime(...) & SetLocalTime(...) .
BuggyMax
|
|
|
|
|
hi
I'm too lazy to login, sorry...
did anybody manage it to compile and link a mfc-app with stlport ?
I get all kinds of compiler- and linker-errors...
tia
-widi
vc6 sp5, platformasdk nov2001, stlport453
|
|
|
|
|
missing some #include somewhere ?
~RaGE();
|
|
|
|
|
I don't think so...
I get errors in afxtempl.h and _ios.h
compiler error 2660: new[] wrong number of arguments blah blah...
most of the stl_user_config stuff does not seem to have an effect..
and yes - I did make a full rebuild after I changed something...
thanks anyway
-widi
|
|
|
|
|
I want to use the print / print preview of the MFC framework.
I want to stretch my dawing on the whole size of the paper.
So, here my question: How can I get the size (in pixel) of the whole paper, so that I can stretch my drawing so that it uses the whole paper.
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Do it like that :
CRect crPrintPaperRect = CRect( 0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES) );
for details have a look at the msdn :
int CDC::GetDeviceCaps( int nIndex )
- HORZSIZE Width of the physical display (in millimeters).
- VERTSIZE Height of the physical display (in millimeters).
- HORZRES Width of the display (in pixels).
- VERTRES Height of the display (in raster lines).
|
|
|
|
|
Thanks! It works!
I use it like in the following code:
if (pDC->IsPrinting())
{
rtClient = CRect(0, 0,
pDC->GetDeviceCaps(HORZRES),
pDC->GetDeviceCaps(VERTRES));
}
else
{
GetClientRect(&rtClient);
}
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
If you want to be really accurate, you should call DeviceCapabilities() to open the device that you will be printing to. One of the parameters to OpenPrinter is a good old DEVMODE struct (lots of good info).
Also, you should look at the PHYSICALOFFSETX and
PHYSICALOFFSETY to determine the non-printable areas of the physical page (YOUR MIN MARGIN). On laser printers, this is usually 0.25 inches around.
|
|
|
|
|
In print/preview in your OnPrint() procedure which generates the output, the paper size can always be found in the CPrintInfo::m_rectDraw object. So you should be able to read this rect value and StretchBlt the pic to this size.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Thanks Roger! It works!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hey guys,
Im only new to this and have got lots of help from other peoples posts before. Now its my turn.
How do you set the window to be maximized upon startup in visual C++?
I've looked everywhere but cant seem to find it!!!
thanx in advance
clubbyr8
|
|
|
|
|
What kind of project do you use ???
If it's a SDI application, go to the InitInstance() function from your application class (C*****App) and replace the line:
m_pMainWnd->ShowWindow(SW_SHOW);
by:
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
Hope this helps
|
|
|
|
|
sorry its an MFC application. Hope this helps out a lil more.
clubbyr8
|
|
|
|
|
Yes ok, but what kind of MFC application? When you create a new MFC project, you can choose the type of application you want to create: single document, multiple document or dialog based.
For a SDI (single doc) or MDI (multiple doc), you can do what I posted in the previous message.
Hope this helps!
|
|
|
|
|
clubbyr8 wrote:
sorry its an MFC application.
What do you mean? Cedric's solution was for MFC.
Lemme spell it for you:
You derive a class from CWinApp , don't you? Let's assume you call it MyApp . When you define the function InitInstance() within that class, you'll have to create a Frame object (typically, but not always instantiated from a class derived from CFrameWnd ) within that using a pointer, which I'll assume you call p . After that, include these lines:
m_pMainWnd=p;
p->ShowWindow(SW_SHOWMAXIMIZED);
return TRUE;
That should work. If it doesn't, something's seriously wrong.
Vikram.
-----------------------------
My site due for a massive update
Radioactive cats have 18 half-lives.
"Do not give redundant error messages again and again." - A classmate of mine, while giving a class talk on error detection in compiler design.
|
|
|
|