|
You're missing the argument to static_cast . Btw, the code looks very suspect. Why do you have a nested if when all you really need to do (imho) is:
if ((riid == IID_IUnknown) ||
(riid == IID_IX) ||
(riid == IID_IY))
*ppvObject = static_cast(this);
else {
ppvObject = NULL;
hr = E_NOINTERFACE;
...
}
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I think you miss ";" at the end of the line " *ppvObject = static_cast ",do you?
free like a bird
|
|
|
|
|
hi every body!!
i have problem that default many child window size.
i want to get that when main window appear different size many child window are default.
i want to know where this sample code.
please give me.
thank all!!!!
phoophoo2004@indiatimes.com
|
|
|
|
|
From MSDN, it says
GetDefaultPrinter is included in Windows 2000 or later.
I am using WIndows XP, and look at the windows.h and winspool.h, I could find the declaration of this function.
In fact I try to run the following sample code provided by MSDN at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/UsingGDIPlus/Printing/SendingGDIPlusOutputtoaPrinter.asp
But it failed by saying the GetDefaultPrinter undefined.
Can anyone help me to fix this problem? Becasue I would like bypass the Printer Diolog using GetDefaultPrinter.
Thanks a lot
David
//-----------------------
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
INT main()
{
// Initialize GDI+.
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
DWORD size;
HDC hdcPrint;
DOCINFO docInfo;
ZeroMemory(&docInfo, sizeof(docInfo));
docInfo.cbSize = sizeof(docInfo);
docInfo.lpszDocName = "GdiplusPrint";
// Get the size of the default printer name.
GetDefaultPrinter(NULL, &size);
// Allocate a buffer large enough to hold the printer name.
TCHAR* buffer = new TCHAR[size];
// Get the printer name.
if(!GetDefaultPrinter(buffer, &size))
{
printf("Failure");
}
else
{
// Get a device context for the printer.
hdcPrint = CreateDC(NULL, buffer, NULL, NULL);
StartDoc(hdcPrint, &docInfo);
Graphics* graphics;
Pen* pen = new Pen(Color(255, 0, 0, 0));
StartPage(hdcPrint);
graphics = new Graphics(hdcPrint);
graphics->DrawRectangle(pen, 50, 50, 200, 300);
delete graphics;
EndPage(hdcPrint);
StartPage(hdcPrint);
graphics = new Graphics(hdcPrint);
graphics->DrawEllipse(pen, 50, 50, 200, 300);
delete graphics;
EndPage(hdcPrint);
delete pen;
EndDoc(hdcPrint);
DeleteDC(hdcPrint);
}
delete buffer;
GdiplusShutdown(gdiplusToken);
return 0;
}
David
|
|
|
|
|
I would like to put some sort of tree structure in an internet explorer side bar but I haven't been able to merge my bar with any of the many types of trees I have learned about these past couple of weeks. Something like the view->explorer bar->folders would be optimal. I hope someone can at least point me in the right direction.
Thanks in advance,
Biggie.
|
|
|
|
|
I use the function
int ExtEscape(
HDC hdc,
int nEscape,
int cbInput,
LPCSTR lpszInData,
in cbOutput,
LPSTR lpszOutData
);
at my program.Because of my poor English,I couldn't understand the function's introduction at Microsoft Windows CE.NET Help.Could you give me a introduction about the function and the use of it in detail?
Thanks!
free like a bird
|
|
|
|
|
The documentation in the Platform SDK covers this in detail, but in brief this function allows you to access driver-specific functions that are not exposed by the Windows GDI. The specific device is passed to the function using its handle, hdc. The device driver function is specified by nEscape, while lpszInData is a pointer to whatever data is required as input for the function. The cbInput parameter specifies the size of the structure indicated by lpszInData in bytes. Similarly, the lpszOutData parameter is a pointer to the structure where you want the results to be stored, and cbOutput contains the size, in bytes, of this structure. ExtEscape returns a positive value if the call is successful, and 0 if the requested function doesn't exist. A negative return value indicates an error. Several predefined values exist for nEscape, primarily related to printers, but other than these you are free to specify any value supported by the target driver.
"My kid was Inmate of the Month at Adobe Mountain Juvenile Corrections Center" - Bumper Sticker in Bullhead City
|
|
|
|
|
Hi
I have just started learning C++ GUI programming using Visual C++ (I'm using VC++ 6), and I have two questions regarding it:
1. Let's say I create a dilog-based project, and I put some things (buttons, lists, etc.). The problem is, when the user maximizes the the dialog, the button placements are not automatically modified, leaving a large part of the maximized window blank. Is there a way to automatically reposition ALL the things inside the dialog when the user maximizes the window (or resizes the window, for that matter)? Or do I need to manually recalculate the correct positions and sizes for all the things and apply them one by one?
2.Is there a tutorial/website that explains how I can create other GUIs beside the document/view or dialog-based GUIs that Visual C++ provides (e.g. skin-based GUI, GUI's with shape other than simple rectangle, etc.)?
Thanks!
|
|
|
|
|
Indrawati wrote:
Is there a way to automatically reposition ALL the things inside the dialog when the user maximizes the window
No.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
MFC doesn't come with a layout manager like Java. However, see this[^] and this[^] CP section for answers.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I just want to know the initializtion of the parameter lpCmdLine. Could you tell me how and where to find it?
thanks!
free like a bird
|
|
|
|
|
lpCmdLine is passed into your program from CRT initialization. The CRT just calls GetCommandLine.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thank you very much,Tim!
free like a bird
|
|
|
|
|
Hello,
I'm just wondering why your message subject is: "To Michael Dunn"?
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
It may be more appropriate to be "Dear Mr. Dunn"!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Recently, I write a program.And I write a WinMain function for it. But I don't know where and how to initialize the parameters of the function. Should I to initialize them by myself? Or the system will intialize them?
Where can I find the initializtion of the parameters
hInstC,hInstP,lpCmdLine,nCmdShow?
the function is as follows:
int PASCAL WinMain(HINSTANCE hInstC, HINSTANCE hInstP, LPTSTR lpCmdLine, int nCmdShow)
{..................}
free like a Bird
|
|
|
|
|
|
Hello All,
I am new to C++ and am trying to do some DSP programming. I would like to write the following function
y(n) = (1-a)*x(n-1) + a*y(n-1)
The arguments to this function are all floats - "x", "y" and "a".
Could somebody help me with this?
|
|
|
|
|
I could help you if you can answer these 2 questions:
(1) is x a function (if so, what is it)?
(2) what's the definition of y(0) ?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks, Ravi.
To answer your questions, this function which I'll call SmoothingFunction, is called by another function by name, SmoothCoeffs().
I have two arrays, Coeff[] and Smooth[], each with 5 elements. Values in the array Coeff[] are "smoothed" and then stored in Smooth[].
Here is the SmoothCoeffs() function:
NUM_ITER is 5.
<br />
inline void cDSP::SmoothCoeffs()<br />
{<br />
float *nStart = &gnCoeff[mnCoeffIndex];<br />
float *nFin = &gnSmooth[mnCoeffIndex];<br />
<br />
for (int i = 0; i < NUM_ITER; i++)<br />
{<br />
SmoothingFunction(nStart, nFin, mnSmoothCoeff);<br />
}<br />
<br />
mnCoeffIndex += NUM_ITER;
<br />
if (mnCoeffIndex >= NUM_COEFF)<br />
mnCoeffIndex = 0;
}<br />
"x" represents an element of Coeff() and "y" represents an element of Smooth().
Hope that helps!
|
|
|
|
|
OK, so that implies x and y are simply floating point values and not functions. But then I'm confused by your original definition, viz:
y(n) = (1-a)*x(n-1) + a*y(n-1)
To me, that says y is a function of n , whose definition includes the value y(n-1) . This is pretty easy to code recursively, but then I need to know the exit condition (eg: y(0) is arbitrarily defined as some value). Assuming y(0) is zero, I think the function you want is:
#define EPSILON 0.0000001
double y
(float n,
float a,
float x)
{
if (fabs (n) < EPSILON)
return (0.0);
return ((1.0 - a)*x*(n - 1.0) + (a*y(n-1)));
} /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi Ravi,
I should've probably defined it as follows:
y[n] = (1-a)*x[n-1] + a*y[n-1]
y[n] and x[n] are the elements of two arrays, Smooth[] and Coeff[] respectively.
|
|
|
|
|
OK, it looks like you've answered your own question, then?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello, Could somebody please post a very simple function which takes a file path as a function, and recursively lists all files and folders found under that path?
I've found a few other examples on the 'net, but they seem to be focused at older C compilers, and just won't compile under Visual Studio.
If somebody could please help out with this, I'd greatly appreciate it!!!
Thanks in advance,
--Jon
|
|
|
|
|