|
"_$h@nky_" wrote: How can i set image on buttons at runtime.
Use LoadImage() instead of LoadBitmap() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
HI,
Currently i am signing my code binaries with the help of microsoft signing tool(signtool). But now i am tring to add two digital signature to the binary. Can any one will help me to find out any solution.
Thanks in advance.
birajendu
CyberG India
Delhi
India
|
|
|
|
|
I want to Bring a window to top. I am using BringWindowToTop() function. But its not working.How can i do it.
|
|
|
|
|
I have no idea what you mean by "it is not working". Did you check the return value of the function? The documentation says that if the function returns zero, you can check why the function failed by calling GetLastError()[^].
You could try SetForegroundWindow()[^] as well.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Please refer SetWindowPos with parameter HWND_TOPMOST . Is this helpful ?
Regards,
Paresh.
|
|
|
|
|
Is the library used for using RPC function in Visual Studio 2008 is RpcRT4.lib?.If not plz specify the excat one .
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
It was in Visual Studio 2003 - that was the last visual studio where I used MS-RPC.
Looking at the Platform SDK that's installed with Visual Studio 2008 (its default install location in in c:\program files\Microsoft SDKs\Windows\), it's still rpcrt4.lib.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am writing a simple (well, not for me =) ) C++ program that consist of using loops to make a game of paper, rock, and scissors for two players.
My question is:
How do I set up the game for two players? Do I use a char player1 char player2 style of syntax formatting? I just need something to start with here. I understand the loops and the game. I just do not know how to set two seperate players that with be making cin>> inputs.
Thanks!
-Nate
|
|
|
|
|
You can have your program ask whose turn, as:
C:\game.exe
Game starts!
Player-A: format = (value, x, y) <-- playser A's turn to input
3, 1, 1
Status:
3 0 0
0 0 0
0 0 0
Player-B: format = (value, x, y) <-- player B's turn to input
5, 3, 1
Status:
3 0 5
0 0 0
0 0 0
......
Maxwell Chen
|
|
|
|
|
Hello,
i want to embed a dialog in an SDI Window. I created a new SDI project
without Doc/View architecure. Then created a new dialog, disabled the border,
system menue etc.. Now, in the designer the dialog looks like en empty gray plane.
I also added a class to this dialog derived from CDialog. I did this with the designers help,
right click on the dialog and "add class".
My goal is to embed this dialog in the ChildView window and make it as large as the ChildView
window. I found an example here on code project thats similiar to my problem but anyway it
doesn't meet my requirements.
So, how can I embed this dialog in the SDI application?
best regards,
cmos
|
|
|
|
|
First:
// Simple MDI child.
class MDIChildWnd : public ClsMDIChildWindow
{
_NO_COPY( MDIChildWnd );
public:
// Construction/destruction.
MDIChildWnd() {;}
virtual ~MDIChildWnd() {;}
// Create a child.
BOOL Create( ClsString& str, ClsMDIMainWindow *pFrame )
{
// We let the base create it for us. This will automatically call the
// OnMDINCCreate() overidable in which we do our thing...
ClsRect rc( CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT );
// Create it.
BOOL bMaximized; if ( pFrame->MDIGetActive( &bMaximized ) == NULL ) bMaximized = TRUE;
return ClsMDIChildWindow::Create( str, WS_VISIBLE | ( bMaximized ? WS_MAXIMIZE : 0 ), rc, pFrame );
}
protected:
// Handle the WM_CLOSE messages.
virtual LRESULT OnClose()
{
// Destroy the window.
MDIDestroy();
return 0;
}
// WM_SIZE handler.
virtual LRESULT OnSize( UINT nSizeType, int nWidth, int nHeight )
{
...........
// Base class.
return ClsMDIChildWindow::OnSize( nSizeType, nWidth, nHeight );
}
// WM_MDICREATE handler.
virtual LRESULT OnMDINCCreate( LPCREATESTRUCT pCS )
{
// Make sure the child has a client edge. NOTE: Simply adding this
// bit to the CREATESTRUCT.dwExStyle will not work...
//
// We do it here like this also because the PreCreateWindow() overide
// will not be called when creating MDI child windows.
ModifyExStyle( 0, WS_EX_CLIENTEDGE );
return TRUE;
}
};
|
|
|
|
|
Second:
// Simple MDI frame.
class MDIFrame : public ClsMDIMainWindow
{
_NO_COPY( MDIFrame );
public:
// Construction/destruction.
MDIFrame() {;}
virtual ~MDIFrame() {;}
protected:
// A child window has been closed.
void OnMDIChildRemoved( ClsMDIChildWindow *pWnd )
{
// Look it up in our array.
for ( int i = 0; i < m_Children.GetSize(); i++ )
{
// Is this the one?
if ( m_Children[ i ] == reinterpret_cast<mdichildwnd>( pWnd ))
{
// Free it and remove the entry
// from the array.
delete pWnd;
m_Children.RemoveAt( i, 1 );
break;
}
}
}
// We do not want the system to erase the background of
// the frame window.
virtual LRESULT OnEraseBkgnd( ClsDC *pDC )
{
return 1;
}
// WM_CLOSE handler.
virtual LRESULT OnClose()
{
// Make sure the children are all destroyed.
while ( m_Children.GetSize()) m_Children[ 0 ]->MDIDestroy();
PostQuitMessage( 0 );
return 0;
}
// WM_SIZE handler.
virtual LRESULT OnSize( UINT nSizeType, int nWidth, int nHeight )
{
// Size the splitter which will in turn size and
// move it's panes.
ClsRect rc, tb;
GetClientRect( rc );
// Does it exist already?
if ( m_Toolbar.GetSafeHWND())
{
// Pass the message on to the toolbar.
m_Toolbar.SendMessage( WM_SIZE, nSizeType, MAKELPARAM( nWidth, nHeight ));
// Adjust client rectangle.
m_Toolbar.GetWindowRect( tb );
rc.Top() += tb.Height();
}
// Setup splitter rectangle. This will automatically
// resize and reposition the panes aswell.
m_Splitter.SetSplitRect( rc );
m_Splitter.RedrawPanes();
return 0;
}
// WM_CREATE overidable.
virtual LRESULT OnCreate( LPCREATESTRUCT pCS )
{
// First the base.
if ( ClsMDIMainWindow::OnCreate( pCS ) == -1 )
return -1;
// Create file/dir treeview.
ClsRect rc( 0, 0, 0, 0 );
if ( m_Tree.Create( this, rc, IDC_FILEDIRTREE, WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS ))
{
// Setup the tree.
m_Tree.ModifyExStyle( 0, WS_EX_CLIENTEDGE );
m_Tree.FileFilter() = _T( "*.c;*.cpp;*.h;*.hpp;*.txt" );
m_Tree.DoubleBuffer() = TRUE;
m_Tree.LoadingTextColor() = RGB( 255, 0, 0 );
if ( m_Tree.SetupTree())
{
// Create splitter.
if ( m_Splitter.Create( this, 0 ))
{
// Setup the splitter and it's panes.
m_Splitter.SetPanes( m_Tree, GetMDIClient()->GetSafeHWND());
m_Splitter.SetPaneMinSize( 100, 100 );
m_Splitter.SetSplitterPosition( 200 );
// Load the menu.
if ( m_Menu.Load( MAKEINTRESOURCE( IDR_MENU )))
{
// Set it up.
m_Menu.ConvertMenus();
MDISetMenu( &m_Menu, m_Menu.GetSubMenu( 0 ));
DrawMenuBar();
// Create toolbar.
if ( m_Toolbar.Create( this ))
// Ready to go...
return 0;
}
}
}
}
return -1;
}
// WM_COMMAND overidable.
virtual LRESULT OnCommand( UINT nNotifyCode, UINT nCtrlID, HWND hWndCtrl )
{
// A toolbar button?
if ( nCtrlID >= IDT_NEW && nCtrlID <= IDT_FULLSCREEN )
{
// Was it the exit button?
if ( nCtrlID == IDT_EXIT )
SendMessage( WM_CLOSE );
else
{
// Do somthing stupid like telling you
// what button you clicked (like you don't know yourself...)
TBBUTTONINFO tbi;
tbi.cbSize = sizeof( tbi );
tbi.dwMask = TBIF_LPARAM;
if ( m_Toolbar.GetButtonInfo( nCtrlID, tbi ))
{
ClsString str;
str.Format( _T( "You clicked the \"%s\" button on the toolbar!" ), tbi.lParam );
MessageBox( str, _T( "MDI Sample" ), MB_ICONINFORMATION | MB_OK );
}
}
}
// Closeup on selecting Exit from the menu.
else if ( nCtrlID == IDM_EXIT )
SendMessage( WM_CLOSE );
// Base class.
return ClsMDIMainWindow::OnCommand( nNotifyCode, nCtrlID, hWndCtrl );
}
// Data.
ClsArray<mdichildwnd> m_Children;
ClsSplitter m_Splitter;
Toolbar m_Toolbar;
FileDirTree m_Tree;
ClsXPMenu m_Menu;
};
|
|
|
|
|
|
Hi,
1) Is it possible to add additional textbox control (or a button) to all open/save file dialogs in winXP and vista?
2) Is it possible to replace them with my application?
Regards,
Gilvini
|
|
|
|
|
Member 4179230 wrote:
1) Is it possible to add additional textbox control (or a button) to all open/save file dialogs in winXP and vista?
See if this search is of any help.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello,
We would like to print some simple drawing output using GDI. We have used the PrintDlgEx function to obtain a device context handle to a printer, but are unsure of how to proceed. We have not been able to find much example code and are a little stuck.
Basically, we have the DC handle. Presumably we then call Rectangle(x,x,x,x) etc to do the painting. What must be done then to initiate the actual printing?
Any help would be appreciated.
Thanks,
Steve
|
|
|
|
|
Check this[^] out, it's a good starting point.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
That is not quite what we were looking for because we are using pure Win32, no MFC. However it did lead me to find this so for that you have my thanks. I spent ages looking on the MSDN site for something like that.
Steve
|
|
|
|
|
char devstring[256]; // array for WIN.INI data
HANDLE printer;
LPDEVMODE devMode = NULL;
DWORD structSize, returnCode;
GetProfileString("Devices", printerName, "", devstring, sizeof(devstring));
char *driver = strtok (devstring, (const char *) ",");
char *port = strtok((char *) NULL, (const char *) ",");
if (!driver || !port) {
MessageBox(win->hwndFrame, "Printer with given name doesn't exist", "Printing problem.", MB_ICONEXCLAMATION | MB_OK);
return;
}
BOOL fOk = OpenPrinter((LPSTR)printerName, &printer, NULL);
if (!fOk) {
MessageBox(win->hwndFrame, _TR("Could not open Printer"), _TR("Printing problem."), MB_ICONEXCLAMATION | MB_OK);
return;
}
HDC hdcPrint = NULL;
structSize = DocumentProperties(NULL,
printer, /* Handle to our printer. */
(LPSTR) printerName, /* Name of the printer. */
NULL, /* Asking for size, so */
NULL, /* these are not used. */
0); /* Zero returns buffer size. */
devMode = (LPDEVMODE)malloc(structSize);
if (!devMode) goto Exit;
// Get the default DevMode for the printer and modify it for your needs.
returnCode = DocumentProperties(NULL,
printer,
(LPSTR) printerName,
devMode, /* The address of the buffer to fill. */
NULL, /* Not using the input buffer. */
DM_OUT_BUFFER); /* Have the output buffer filled. */
if (IDOK != returnCode) {
// If failure, inform the user, cleanup and return failure.
MessageBox(win->hwndFrame, "Could not obtain Printer properties", "Printing problem.", MB_ICONEXCLAMATION | MB_OK);
goto Exit;
}
..........
if (bitmapDx >bitmapDy) {
devMode->dmOrientation = DMORIENT_LANDSCAPE;
} else {
devMode->dmOrientation = DMORIENT_PORTRAIT;
}
DocumentProperties(NULL,
printer,
(LPSTR) printerName,
devMode, /* Reuse our buffer for output. */
devMode, /* Pass the driver our changes. */
DM_IN_BUFFER | /* Commands to Merge our changes and */
DM_OUT_BUFFER); /* write the result. */
ClosePrinter(printer);
hdcPrint = CreateDC(driver, printerName, port, devMode);
if (!hdcPrint) {
MessageBox(win->hwndFrame, "Couldn't initialize printer", "Printing problem.", MB_ICONEXCLAMATION | MB_OK);
goto Exit;
}
PRINTPAGERANGE pr;
pr.nFromPage =1;
pr.nToPage =win->dm->pageCount();
if (CheckPrinterStretchDibSupport(win->hwndFrame, hdcPrint))
PrintToDevice(win->dm, hdcPrint, devMode, 1, &pr , pt);
Exit:
free(devMode);
DeleteDC(hdcPrint);
}
|
|
|
|
|
static bool CheckPrinterStretchDibSupport(HWND hwndForMsgBox, HDC hdc)
{
// most printers can support stretchdibits,
// whereas a lot of printers do not support bitblt
// quit if printer doesn't support StretchDIBits
int rasterCaps = GetDeviceCaps(hdc, RASTERCAPS);
int supportsStretchDib = rasterCaps & RC_STRETCHDIB;
if (supportsStretchDib)
return true;
MessageBox(hwndForMsgBox, "This printer doesn't support StretchDIBits function", "Printing problem.", MB_ICONEXCLAMATION | MB_OK);
return false;
}
static void PrintToDevice(DisplayModel *dm, HDC hdc, LPDEVMODE devMode, int nPageRanges, LPPRINTPAGERANGE pr, int printRange = 0) {
................
DOCINFO di = {0};
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = filename;
if (StartDoc(hdc, &di) <= 0)
return;
.................
SetMapMode(hdc, MM_TEXT);
int printAreaWidth = GetDeviceCaps(hdc, HORZRES);
int printAreaHeight = GetDeviceCaps(hdc, VERTRES);
int topMargin = GetDeviceCaps(hdc, PHYSICALOFFSETY);
int leftMargin = GetDeviceCaps(hdc, PHYSICALOFFSETX);
.........
// use pixel sizes for printer with non square pixels
float fLogPixelsx= (float)GetDeviceCaps(hdc, LOGPIXELSX);
float fLogPixelsy= (float)GetDeviceCaps(hdc, LOGPIXELSY);
bool bPrintPortrait=fLogPixelsx*printAreaWidth<flogpixelsy*printareaheight;>
BOOL isSameFile = IsSameFile(dm);
int realWidth = printAreaWidth;
int realHeight = printAreaHeight;
// print all the pages the user requested unless
// bContinue flags there is a problem.
for (int i=0; i < nPageRanges; i++) {
assert(pr->nFromPage <= pr->nToPage);
for (DWORD pageNo = pr->nFromPage; pageNo <= pr->nToPage; pageNo++) {
............
StartPage(hdc);
..............
bmp->stretchDIBits(hdc, leftMargin, topMargin, realWidth, realHeight);
delete bmp;
if (EndPage(hdc) <= 0) {
AbortDoc(hdc);
return;
}
}
pr++;
}
Error:
EndDoc(hdc);
}
|
|
|
|
|
also you can do like this:
PRINTDLGEX pd;
LPPRINTPAGERANGE ppr=NULL;
.......
ZeroMemory(&pd, sizeof(PRINTDLGEX));
pd.lStructSize = sizeof(PRINTDLGEX);
pd.hwndOwner = hwndFrame;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE | PD_NOSELECTION;
pd.nCopies = 1;
/* by default print all pages */
pd.nPageRanges =1;
pd.nMaxPageRanges = MAXPAGERANGES;
ppr = (LPPRINTPAGERANGE)malloc(MAXPAGERANGES*sizeof(PRINTPAGERANGE));
pd.lpPageRanges = ppr;
ppr->nFromPage = 1;
ppr->nToPage = dm->pageCount();
pd.nMinPage = 1;
pd.nMaxPage = dm->pageCount();
pd.nStartPage = START_PAGE_GENERAL;
if (PrintDlgEx(&pd) == S_OK) {
if (pd.dwResultAction==PD_RESULT_PRINT) {
if (CheckPrinterStretchDibSupport(hwndFrame, pd.hDC)){
if (pd.Flags & PD_CURRENTPAGE) {
pd.nPageRanges=1;
pd.lpPageRanges->nFromPage=currentPageNo();
pd.lpPageRanges->nToPage =currentPageNo();
} else if (!(pd.Flags & PD_PAGENUMS)) {
pd.nPageRanges=1;
pd.lpPageRanges->nFromPage=1;
pd.lpPageRanges->nToPage =pageCount();
}
PrintToDevice(dm, pd.hDC, (LPDEVMODE)pd.hDevMode, pd.nPageRanges, pd.lpPageRanges);
}
}
}
else {
if (CommDlgExtendedError()) {
/* if PrintDlg was cancelled then
CommDlgExtendedError is zero, otherwise it returns the
error code, which we could look at here if we wanted.
for now just warn the user that printing has stopped
becasue of an error */
MessageBox(win->hwndFrame, "Cannot initialise printer", "Printing problem.", MB_ICONEXCLAMATION | MB_OK);
}
}
free(ppr);
if (pd.hDC != NULL) DeleteDC(pd.hDC);
if (pd.hDevNames != NULL) GlobalFree(pd.hDevNames);
if (pd.hDevMode != NULL) GlobalFree(pd.hDevMode);
}
|
|
|
|
|
You will need to put all GDI calls between StartDoc /EndDoc and StartPage /EndPage APIs.
The Doc indicates a print job and the Page indicates a new page.
So basically you will have one pair of StartDoc /EndDoc and several pairs of StartPage /EndPage (One for each page).
«_Superman_»
|
|
|
|
|
|
I'm trying to compile the SysInternals Native app[^] for XP x64 (and other Windows x64 ), so I can create an app which can run during boot-time (similar to chkdsk), but am not having much luck. As SysInternals have stopped supplying native.xip, you can get it from
http://www.dowers.net:8080/ftp/Programs/InsideWin2000/Sysinternals-Website/NATIVE.ZIP[^]
I've installed the Windows Server 2003 DDK, and have started a Windows Server 2003 Free x64 Build environment (using the shortcut). I've then copied all the Native sources and makefile to ddk\inc, as instructed to do so at the bottom of the linked article. However, when I run build.exe, I get two identical errors:
C:\WINDDK\3790~1.183\inc>build
BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.
BUILD: Using 4 child processes
BUILD: Object root set to: ==> objfre_wnet_AMD64
BUILD: Compile and Link for AMD64
BUILD: Computing Include file dependencies:
BUILD: Examining c:\winddk\3790~1.183\inc directory for files to compile.
c:\winddk\3790~1.183\inc - 1 source files (82 lines)
BUILD: Saving C:\WINDDK\3790~1.183\build.dat...
BUILD: Compiling (NoSync) c:\winddk\3790~1.183\inc directory
1>errors in directory c:\winddk\3790~1.183\inc
1>c:\winddk\3790~1.183\bin\makefile.new(1106) : error U1050: Setting TARGETPATH=
C:\WINDDK\3790~1.183\lib in .\sources is not valid - please use obj.
BUILD: nmake.exe /nologo BUILDMSG=Stop. -i NTTEST= UMTEST= NOLINK=1 NOPASS0=1 PA
SS1_NOLIB=1 AMD64=1 failed - rc = 2
BUILD: Compiling c:\winddk\3790~1.183\inc directory
100>c:\winddk\3790~1.183\bin\makefile.new(1106) : error U1050: Setting TARGETPAT
H= C:\WINDDK\3790~1.183\lib in .\sources is not valid - please use obj.
BUILD: nmake.exe failed - rc = 2
BUILD: Compile errors: not linking c:\winddk\3790~1.183\inc directory
BUILD: Done
0 files compiled - 2 Errors
What exactly does the error mean ?
1>c:\winddk\3790~1.183\bin\makefile.new(1106) : error U1050: Setting TARGETPATH=
C:\WINDDK\3790~1.183\lib in .\sources is not valid - please use obj.
How can I fix it ?
Is there any good information on how to correctly setup a build environment for building native apps for both x86 and x64 ?
|
|
|
|
|
You might have much better luck posting your question on a site that's devoted to driver development. They know all about this kind of stuff.
Try this site:
http://www.osronline.com/[^]
Good luck!
|
|
|
|
|