|
Hi,
I made a project to read event log (very good project about this on this site !), but i have a big pb : my FormatMessage function return the error code 317 (ERROR_MR_MID_NOT_FOUND) every time i tri to read in the message file.
If anybody has a suggestion !
Thanks
tatazou
|
|
|
|
|
The error is
"The system cannot find message for message number 0x%1 in message file for %2"
The event log does not store the text of the error messages it displays. what it knows is that the following application had the error number xxx . To show the error it queries the registry for the corresponding resource DLL path.
This DLL has a Tabel that Maps the error code to the strings that the Event Log program shows.
This DLL is pre compiled and used by the application. To compile the resource DLL use the message compiler MC from the command line.
So you either missing the reource DLL
or the Registry key is not updated correctly
Cheers
G. ALfadhly
<marquee>
It is not polite to point. Don't interrupt. Say `please' and `thank you'. Keep your head, your temper, your cool. Smile!
Try to remember the names of people you are introduced to. Listen.
etiquitte
|
|
|
|
|
Hi,
I made a lot of test, and there's the result :
My EventID value is not all the time valid : sometime (for DrWatson event ie), i have to make or (|) if i want to get the right message (for DrWatson, it's 0x40000000). Do you know if exist a variable i have to check to resolve my pb !
Thank's a lot !
Tatazou
|
|
|
|
|
I am having a lot of trouble with this.
In an MDI App trying to detect when the user has let go of the view window after resizing.
I found WM_EXITSIZEMOVE, but it only detects when re-sizing the Frame has finished and doesn't work in the view even if you create your own message handler.
|
|
|
|
|
Put this in CChildFrame, and this should sort out your problem
Regards
Norm
afx_msg LRESULT OnExitSizeMove(WPARAM wParam, LPARAM lParam);
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFrame)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_EXITSIZEMOVE, OnExitSizeMove)
END_MESSAGE_MAP()
LRESULT CChildFrame::OnExitSizeMove(WPARAM wParam, LPARAM lParam)
{
return 0;
}
|
|
|
|
|
How can I change a color of an existing pen without creating a new one ?
I found a function like SetDCPenColor for NT. Is there in simular one for Win9x ?
Greatings Mario ///
----------------------
www.klangwerker.de
mario@klangwerker.de
----------------------
|
|
|
|
|
Actually, SetDCPenColor is only in Win2k and only applies to the DC_PEN stock object.
What is it that you're trying to do that prohibits you from creating a new pen?
|
|
|
|
|
I`m trying to implement a class that simulates a LCD-display --- during constructor call i need several pens with different colors to draw a scolled-frame around the rect of the display. That function works but create,reselect and delete pens takes a lot of time and my member-function is not the fastest.
What i want is getting one pen in a loop - change the pen-color during every loop-cycle and put a new frame-rect around the previous one.
Greatings Mario
P.S.: I don`t use MFC !
--------------------
www.klangwerker.de
rocknix@lycos.de
--------------------
|
|
|
|
|
I want to get a snapshot of the desktop, so I am trying to 'hide' the calling window, get the snapshot and then show the window and blit the snapshot to it's DC.
It works, but it seems to be capturing the calling DC (the one I'm hiding)....?
Here's the code:
///////////////////////////////////////////////////////////////////////////////////////////////////////////Function Header
void CDCUtils::PaintDesktop( CDC *pDC, CWnd* pWnd, CRect rect, bool bHideWindow )
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
CDC dcDesktop;
CDC dcBuffer;
CBitmap bmpBuffer;
CBitmap bmpDesktop;
CRect LastRect;
CWnd* pFrameWnd = pWnd->GetParentFrame();
pFrameWnd->GetWindowRect( LastRect );
//CPoint Point( rect.left, rect.top );
//HWND hWnd = pWnd->GetSafeHwnd();
//ClientToScreen(hWnd, &Point);
CPoint Point( LastRect.left, LastRect.top );
// Get the Calling Window out the way, so that we can get a clean snapshot...
if ( bHideWindow)
{
pFrameWnd->SetWindowPos( NULL, -100,0,0,0, NULL );
Sleep(400);
}
//
// Get the Desktop's Device Context
//
dcDesktop.m_hDC = ::GetDC(NULL);
//
// Initialise the bitmap according to the Desktop DC
//
bmpDesktop.CreateCompatibleBitmap( &dcDesktop,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN));
//
// Create a buffer DC that has a bmp associated with it
//
dcBuffer.CreateCompatibleDC(&dcDesktop);
dcBuffer.SelectObject(bmpDesktop);
//
// Blit from the Desktop's (point.x, point.y) to the buffer's rectangle: 0,0,width,height
//
dcBuffer.BitBlt( 0,
0,
rect.Width(),
rect.Height(),
&dcDesktop, // From DC
Point.y,
Point.y,
SRCCOPY);
if ( bHideWindow)
{
pFrameWnd->SetWindowPos( NULL, LastRect.left, LastRect.top, LastRect.Width(), LastRect.Height(), NULL );
}
pDC->BitBlt( rect.left,
rect.top,
rect.Width(),
rect.Height(),
&dcBuffer, // From DC
0,
0,
SRCCOPY);
dcDesktop.DeleteDC();
dcBuffer.DeleteDC();
bmpDesktop.DeleteObject();
bmpBuffer.DeleteObject();
}
|
|
|
|
|
>if ( bHideWindow) { pFrameWnd->SetWindowPos( NULL, -100,0,0,0, NULL ); Sleep(400);
I dunno, but why do you do the above ? Why the wait, and why not pFrameWnd->ShowWindow(SW_HIDE); ?
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Thanks for the reply,
Yes, I had started out with a simple SW_HIDE, but when it still didn't work, I went overboard just to MAKE SURE , and put the wait so that even I could tell with my own eyes that the window was not being shown while the snapshot was taken.
|
|
|
|
|
This is just a copy->paste from MSDN:
You can use a bitmap to capture an image, and you can store the captured image in memory, display it at a different location in your application's window, or display it in another window.
In some cases, you may want your application to capture images and store them only temporarily. For example, when you scale or zoom a picture created in a drawing application, the application must temporarily save the normal view of the image and display the zoomed view. Later, when the user selects the normal view, the application must replace the zoomed image with a copy of the normal view that it temporarily saved.
To store an image temporarily, your application must call CreateCompatibleDC to create a DC that is compatible with the current window DC. After you create a compatible DC, you create a bitmap with the appropriate dimensions by calling the CreateCompatibleBitmap function and then select it into this device context by calling the SelectObject function.
After the compatible device context is created and the appropriate bitmap has been selected into it, you can capture the image. The BitBlt function captures images. This function performs a bit block transfer — that is, it copies data from a source bitmap into a destination bitmap. However, the two arguments to this function are not bitmap handles. Instead, BitBlt receives handles that identify two device contexts and copies the bitmap data from a bitmap selected into the source DC into a bitmap selected into the target DC. In this case, the target DC is the compatible DC, so when BitBlt completes the transfer, the image has been stored in memory. To redisplay the image, call BitBlt a second time, specifying the compatible DC as the source DC and a window (or printer) DC as the target DC.
The following example code, from an application that captures an image of the entire desktop, creates a compatible device context and a bitmap with the appropriate dimensions, selects the bitmap into the compatible DC, and then copies the image using the BitBlt function.
hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);
hdcCompatible = CreateCompatibleDC(hdcScreen);
hbmScreen = CreateCompatibleBitmap(hdcScreen,
GetDeviceCaps(hdcScreen, HORZRES),
GetDeviceCaps(hdcScreen, VERTRES));
if (hbmScreen == 0)
errhandler("hbmScreen", hwnd);
if (!SelectObject(hdcCompatible, hbmScreen))
errhandler("Compatible Bitmap Selection", hwnd);
ShowWindow(hwnd, SW_HIDE);
if (!BitBlt(hdcCompatible,
0,0,
bmp.bmWidth, bmp.bmHeight,
hdcScreen,
0,0,
SRCCOPY))
errhandler("Screen to Compat Blt Failed", hwnd);
ShowWindow(hwnd, SW_SHOW);
Hope it helps...
- Anders
|
|
|
|
|
Hi,
I would like to give my window it's own unique class name. However, because I'm using MFC I have to use AfxRegisterWndClass() which makes up a name for itself. I want to be able to give it a more 'user-friendly' name.
Does anyone know how to get around this?
Cheers
James
|
|
|
|
|
You can use AfxRegisterClass() instead. You provide a WNDCLASS struct to this function, so you can name your class anything you like.
--Mike--
http://home.inreach.com/mdunn/
Is history an illusion caused by the passage of time, or is time an illusion caused by the passage of history?
|
|
|
|
|
my view is derived from CEditView and need to get the CEdit pointer back so I can use the function LineScroll(..) from within the view class itself! am I stock or someone knows it! please.
|
|
|
|
|
Inside the class, you would do something like:
GetEditCtrl( ).LineScroll()
Hope this helps.
|
|
|
|
|
Perfect! Thankx!
One problem though, the LineScroll(....) does not scroll!
One thing am stock with is this scenario:
I have a dialog that is modal, I enter text into an Editbox on it and then add this dialogs text into the edit box of the view! But once I add another text, it just appends to the end of the last existing text. What I need is to scroll the cursor down, something like as if I pressed the Enter key while in the view's text editor area!
this is my code fragment:
<br />
<br />
<br />
void CTestView::OnInsertText() <br />
{<br />
<br />
CNewString dlg;<br />
<br />
CEdit *pEdit = (CEdit*) &GetEditCtrl();<br />
ASSERT(pEdit);<br />
<br />
UINT result = dlg.DoModal();<br />
<br />
if(result==IDOK){<br />
<br />
m_NewString += dlg.m_String; <br />
pEdit->SetWindowText(m_NewString);<br />
<br />
pEdit->LineScroll(1);
<br />
}<br />
<br />
}<br />
<br />
|
|
|
|
|
One example to clarify is the Output window of Visual Studio, in the Build tab That's what I desire to accomplish!
|
|
|
|
|
Hi
CEdit *pEdit = (CEdit *) this;
Best Regards ! Vova
|
|
|
|
|
Thanx!
I got another question, I posted two replies to Jason's reply, please check and let me know!
|
|
|
|
|
Hello All
I've been looking for a way to use a different font for my editor in Visual C++.. All the other tools in the Visual Studio suite allows the use of MANY fonts. For some reason VC++ only allows a few.. I have to perfect setup on Visual Interdev and it drives me nuts when I switch to VC++.. Does anyone have any suggestions..
Thanks
Chris
|
|
|
|
|
Tools->Options->Format tab. Click "Source Windows" in the left-hand list and then pick a new font and size.
--Mike--
http://home.inreach.com/mdunn/
Is history an illusion caused by the passage of time, or is time an illusion caused by the passage of history?
|
|
|
|
|
I want to play a sound file when i click a butten, but i cant really find anyhelp on this one..
it sounds easy, so i think it is but i cant figure it out... Im new
ps. How do i make a butten open a app off my chose?? like i want to make a menu for my games...
Thank you...
|
|
|
|
|
I want to play a sound file when i click a butten, but i cant really find anyhelp on this one..
it sounds easy, so i think it is but i cant figure it out... Im new
ps. How do i make a butten open a app off my chose?? like i want to make a menu for my games...
Thank you...
|
|
|
|
|
Very easy - just handle the clicking of the button ( in class wizard ) and PlaySound(filepath, NULL, SND_NODEFAULT);
ShellExecute will allow you to run an app programatically - from MSDN:
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpVerb,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
Parameters
hwnd
Handle to a parent window. This window receives any message boxes that an application produces. For example, an application may report an error by producing a message box.
lpVerb
A string, referred to as a verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's context menu are available verbs. For more information about verbs and their availability, see Object Verbs. See Extending Context Menus for further discussion of context menus. The following verbs are commonly used: Verb Description
edit Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.
explore Explores the folder specified by lpFile.
find Initiates a search starting from the specified directory.
open Opens the file specified by the lpFile parameter. The file can be an executable file, a document file, or a folder.
print Prints the document file specified by lpFile. If lpFile is not a document file, the function will fail.
properties Displays the file or folder's properties.
If you set this paramater to NULL:
For systems prior to Microsoft® Windows® 2000, the default verb is used if it is valid and available in the registry. If not, the "open" verb is used.
For Windows 2000 and later systems, the default verb is used if available. If not, the "open" verb is used. If neither verb is available, the system uses the first verb listed in the registry.
lpFile
Address of a null-terminated string that specifies the file or object on which to execute the specified verb. To specify a shell namespace object, pass the fully-qualified parse name. Note that not all verbs are supported on all objects. For example, not all document types support the "print" verb.
lpParameters
If the lpFile parameter specifies an executable file, lpParameters is an address to a null-terminated string that specifies the parameters to be passed to the application.The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.
lpDirectory
Address of a null-terminated string that specifies the default directory.
nShowCmd
Flags that specify how an application is to be displayed when it is opened. If lpFile specifies a document file, the flag is simply passed to the associated application. It is up to the application to decide how to handle it.
SW_HIDE Hides the window and activates another window.
SW_MAXIMIZE Maximizes the specified window.
SW_MINIMIZE Minimizes the specified window and activates the next top-level window in the z-order.
SW_RESTORE Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window.
SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window remains active.
SW_SHOWNA Displays the window in its current state. The active window remains active.
SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active.
SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
Return Values
Returns a value greater than 32 if successful, or an error value that is less than or equal to 32 otherwise. The following table lists the error values. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Microsoft® Windows® applications. It is not a true HINSTANCE, however. The only thing that can be done with the returned HINSTANCE is to cast it to an integer and compare it with the value 32 or one of the error codes below.
0 The operating system is out of memory or resources.
ERROR_FILE_NOT_FOUND The specified file was not found.
ERROR_PATH_NOT_FOUND The specified path was not found.
ERROR_BAD_FORMAT The .exe file is invalid (non-Win32® .exe or error in .exe image).
SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid.
SE_ERR_DDEBUSY The DDE transaction could not be completed because other DDE transactions were being processed.
SE_ERR_DDEFAIL The DDE transaction failed.
SE_ERR_DDETIMEOUT The DDE transaction could not be completed because the request timed out.
SE_ERR_DLLNOTFOUND The specified dynamic-link library was not found.
SE_ERR_FNF The specified file was not found.
SE_ERR_NOASSOC There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
SE_ERR_OOM There was not enough memory to complete the operation.
SE_ERR_PNF The specified path was not found.
SE_ERR_SHARE A sharing violation occurred.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|