|
Hello all
I have a application that reads the message sent from the printer.
the printer sends the window message, like DOC_START.
I have to register the same message that the printer registered.
<br />
BlackIcePrintMessage = RegisterWindowMessage(szREGISTERMESSAGE);<br />
if (!BlackIcePrintMessage)<br />
{<br />
dwError = GetLastError();<br />
return 0;<br />
} <br />
but how to get/read the message sent from printer..
here the sample code, it works.. but i'm using MFC, dialog based application and the sample code is not for MFC.. the sample code uses WNDCLASS wc and then register with RegisterClass(&wc).
<br />
int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)<br />
{<br />
..<br />
..<br />
..<br />
WNDCLASS wc;<br />
<br />
<br />
wc.style = 0;<br />
wc.lpfnWndProc = TestWndProc;<br />
wc.cbClsExtra = 0;<br />
wc.cbWndExtra = 0;<br />
wc.hInstance = hInst;<br />
wc.hIcon = LoadIcon(hInst, TEXT("TestIcon"));<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);<br />
wc.lpszMenuName = TEXT("TESTMENU");<br />
wc.lpszClassName = szMyClass;<br />
<br />
if (!RegisterClass(&wc))<br />
return FALSE;<br />
HWND hwndMyWindow = CreateWindow(szMyClass, TEXT("Black Ice printer Driver Message Capture Sample"),<br />
WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, 0,<br />
CW_USEDEFAULT, 0, NULL, NULL,<br />
hInst, NULL );<br />
<br />
if ( !hwndMyWindow )<br />
return FALSE;<br />
<br />
ShowWindow (hwndMyWindow, SW_SHOW);<br />
<br />
while ( GetMessage(&msg, NULL, 0, 0 ) )<br />
{<br />
TranslateMessage(&msg);
DispatchMessage(&msg);
}<br />
return (int) msg.wParam;
how can i also register my window class? would it be a right thing to use CCmdTarget class?
Thank you
|
|
|
|
|
Look up ON_REGISTERED_MESSAGE in MSDN for example on how to handle registered messages.
Ignore the sample code for WinMail (that you posted) - you do not need it in MFC.
Get trial copy of comment generating tool CommentMakerPro, std::string and std::string containers viewer FeinEvaluatorPro and windows manager for Microsoft Visual Studio .NET FeinWindows at www.FeinSoftware.com
|
|
|
|
|
Thank you very much..
it is really really helpful hint.
|
|
|
|
|
Hello!!
i'm starting with MFC, and i created a SDI app. I've got the main window (a CFrameWnd) and i want to add a listbox. In the
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
i wrote this line (before that wrote m_LBoxPpal as a CListBox object atribute to the CMainFrame class) :
this->m_LBoxPpal.Create(WS_CHILD | WS_VISIBLE | WS_BORDER,CRect(100, 40, 400, 500),this,ID_LBoxPpal);
and it creates me a listbox. Now i want to add scroll bars to it. Is this an efficient way to do it? I know how to edit dialogs with the resorce editor (to add buttons and stuff). How can i do it with a CFrameWnd?
Thanks!
|
|
|
|
|
If you want to add the scroll bar into the listbox, just specify 'WS_VSCROLL' for a vertical (up-down) scrollbar and 'WS_HSCROLL' for a horizontal (left-right) scrollbar to the style flags of the listbox (WS_CHILD, WS_VISIBLE, WS_BORDER). Using the list-box style flag 'LBS_DISABLENOSCROLL' will prevent the scrollbars from being hidden when there are less than the required amount of items in the box for the scrollbar to appear normally. By default, the scrollbar is hidden if there are not enough many items.
If you desire the scrollbars for the frame window, you need to step into a function called 'PreCreateWindow'. If this function does not exist for your CFrameWnd-derived class, you can use ClassWizard to add it. Then use boolean-OR operation '|' to add style flags into the CREATESTRUCT structure's 'style' member. For example:
BOOL PreCreateWindow( CREATESTRUCT cs )
{
cs.style =| WS_HSCROLL | WS_VSCROLL;
...
} This would add the scrollbars to your frame window. Hope these tips will help you out.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
|
Hi Everybody,
I am trying to write a platform independent C++ library.
I have seen some C++ code in the past where __WINDOWS__ or __WIN32__ is used for windows includes and __UNIX__ for solaris includes. But when I try to use it, it does not work.
1. Do we need to explicity #define these?
2. If yes, where in the code do we do that and how?
Any help would be greatly appreciated.
Thanks,
-Mahesh Shimpi
Ideas multiply by sharing!!
|
|
|
|
|
Mash wrote:
1. Do we need to explicity #define these?
Yes.
Mash wrote:
2. If yes, where in the code do we do that and how?
The actual defines are passed to the compiler. In the code you then do a
#ifdef WIN32<br />
... Do stuff, that is specific to windows, say an optimised verison of a socket class.<br />
class Socket...<br />
class ThreadWrapper<br />
#else<br />
... Do stuff for Unix in here, if you are only working with 2 platforms.<br />
class Socket...<br />
class ThreadWrapper<br />
#endif
Each class will have the same public methods, but depending on the comiler you use will then only compile the code wrapped by the defines passed to it.
A good example of using the defines can be seen when writting plain C++ dll library classes where the classes need to be exported into the function table with a __declspec(dllexport) and need to be imported by the code that used the library with the class headers preceeded by a __declspec(dllimport)
To see this in VS.NET, create a new Win32 project, and make it a dll class library project, and select export symbols, which is where the defines are used for the liker.
#ifdef MYLIB_EXPORTS // specified in compiler options<br />
#define MYLIB_API __declspec(dllexport)<br />
#else<br />
#define MYLIB_API __declspec(dllimport)<br />
#endif<br />
<br />
class MYLIB_API CSampleClass {<br />
public:<br />
CSampleClass(void);<br />
};
A good thing to do would be to have a look an an existing cross platform library like wxWindows, which is an MFC like gui library for Linux and Windows.
http://www.wxwindows.org/[^]
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
Thanks for the clarification Giles.
I can use it now. I defined the respective flags during compilation and used them in the code.
Thanks once again.
-Mahesh Shimpi
Ideas multiply by sharing!!
|
|
|
|
|
_WIN32 is always defined when compiling with Visual C++. I do not know if there is an equivalent which is always defined for GCC, for example.
|
|
|
|
|
You should look at tools like GNU autoconf/automake. I don't know if they work on windows, but they help a lot in dealing with the differences between various Unix versions.
Of course if you only target one Unix (Solaris) you won't care, and even with two it might not be worth the trouble. If you want to make an attempt at supporting more (say all of them...) you will want some help.
|
|
|
|
|
How can I reach pixels of an pictureBox for changing their color attributes.
|
|
|
|
|
IPicture interface returns HDC
HRESULT get_CurDC(
HDC* phdcOut //Receives a pointer to device context
);
Use
COLORREF GetPixel(
HDC hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
COLORREF SetPixel(
HDC hdc, // handle to DC
int X, // x-coordinate of pixel
int Y, // y-coordinate of pixel
COLORREF crColor // pixel color
);
|
|
|
|
|
I've recently upgraded (downgraded, you decide which) to VStudio 7.1 from VC6 and start development of a new app. Everything was working fine (cursing was being kept to a minimum) when the properties window decide to stop displaying properties, i.e., the window appears but with no fields - just a big blank gray window!
Any suggestions on how to get it back? (Its really tough designing dialogs without the property window!!)
Regards,
Kylur.
|
|
|
|
|
The property window displays the properties of the active dialog/class. Remember to click on the dialog or the class implementation file (Open it, and click somewhere) to update the properties window.
If this does not help, back up your projects, uninstall both VC6 and VC7, then do a fresh install of VC7. I have never experienced this problem myself, so it might be a result of unsuccesfull installation.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I've just started a new MFC program and the main window opens with a size i'd like to change.
there's no create i can find. How do i resize the window? should i do it in the CMainFrame::OnCreate?
thanks
|
|
|
|
|
see "The MFC Answer Book", E. Kain, FAQ 3.9.
Basically put a MoveWindow(...) in the OnCreate method.
Regards,
Kylur
|
|
|
|
|
Hi,
Use PreCreateWindow to set initial CMainFrame size.
////////////////////////////////////////
// Set initial window size to 200 x 200
//
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
BOOL bRet = CFrameWnd::PreCreateWindow(cs);
cs.cx = cs.cy = 200;
return bRet;
}
Oleg.
|
|
|
|
|
|
Dear all,
How to set the delay time for the ToolTips control unlimited? I used the function SetDelayTime(TTDT_AUTOPOP, iDelayTime), but it seemed that the iDelayTime couldn't be greater than 5000 miliseconds. Thanks .
Best regards.
____
Tuan
|
|
|
|
|
Hi,
I'm trying to view some resultes in a list box and I can not see all of them because I do no have a horizontal scroll bar. I checked the horizontal scroll bar in the options of the List box, but still I get only the vertical scroll bar.
tx...
Mirelutza
|
|
|
|
|
I think you have horizontal and vertical confused. A horizontal scroll bar is on the bottom, and a vertical scroll bar is on the right. A horizontal scroll bar is not going to care how many items are in the list, and a vertical scroll bar is not going to care how long each item is. See the difference?
It sounds like you need to send the LB_SETHORIZONTALEXTENT message. Or if you are using MFC, call the SetHorizontalExtent() method.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hello again,
I tried to send a message like you told me,but still it's not working. Am I doing something wrong by calling:
SendMessage(hDlg,LB_SETHORIZONTALEXTENT,25,0);
Regards
Mirelutza
|
|
|
|
|
>SendMessage(hDlg,LB_SETHORIZONTALEXTENT,25,0);
SendMessage(hListBox,LB_SETHORIZONTALEXTENT,25,0);
Message has to go to the ListBox window.
|
|
|
|
|
Hi,
The handle to the list box is an int and in the SendMessage function the firs parameter si HWND, and even if I upcast the int to HWND it's not working...
The ListBox is in the hDlg window which is a dialog box. In the dialog box I have some more objects, so if I send the message to the Dlg window is not right.
I even tried to get the HWND parameter of the listbox with getdlgitem function and still it's not working.Do you have any sugestions...???
Tx
Mirelutza
|
|
|
|
|