|
Thanks for the information, Eric!
I will be running Windows XP.
Can those APIs be used stand-alone, or do I have to use some sort of class thing? What inculdes do I have to put into my programs? Do you have a simple example?
Again, thanks!
Bill
|
|
|
|
|
Hi Bill,
To answer about the APIs: They are available for your use in a program without creating additional classes, they are supplied as part of Windows and your VC++ 4 compiler should let you write programs that call them.
About the includes: To be honest, I'm not sure of the actual #includes needed to access them. The reason is that I take it for granted that they will be provided automatically by App Wizard (the tool provided in VC++) when I create the program skeleton.
Are you familiar with using App Wizard to generate a program skeleton? This will help answer about a sample program.
Best,
Eric
|
|
|
|
|
Hi,
I'd like to copy the content of a Flexgrid (MS FlexGrid Control version 6.0)to a Word or Excel document. I tried "InvokeHelper(0x37, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);" hoping it would copy a picture to the clipboard but it doesn't.
Ideally, I would like to copy not a picture but the actual data as a table to Excel.
Many thanks in advance for your help.
Franck
|
|
|
|
|
I have specified in my "Open" CFileDialog to show only jpg and bmp files. But how to prevent from showing shortcuts to jpg or bmp files that are in other directories?
|
|
|
|
|
Hello @all,
how can I create a twodimensional array with a variable length?
Thank you very much!
Lucky
|
|
|
|
|
I think your best bet is use a vector.
- Nick Parker My Blog
|
|
|
|
|
Or you can use any of free matrix libraries (for example Newmat). Many of them have the same design as STL containers. Try google to find them.
Robert-Antonio
"I launched Norton Commander and saw, drive C: on the left, drive C: on the right...I said, damn, why I need two drives C:??? So I formatted one..."
|
|
|
|
|
I have been trying to use Stephan Keil's DlgResizeHelper to resize my MFC dialog based application.
The main dialog has a bitmap loaded onto it (the whole of it). This is using the CBDialog class to load the Bitmap onto the initial dialog.
Also I am using HoverButton by Niek Albers for 30 buttons on this dialog.
The dialog also makes use of a Picture control and an Animation control, together with a few edit and checkboxes controls.
The DlgResizeHelper almost works but get the original bitmap that the dialog had loaded is still on display when the dialog is enlarged. Also the HoverButtons bitmaps get a bit too large when the dialog is enlarged.
Are they a solution to these problems or are they another resizer that will do all of the above?
Regards,
Grahamfff
grahamfff
|
|
|
|
|
Having problem running my program after simply adding a second control variable through the classwizard for an editbox.
Is there a limit or something ?
Someone know what the problem is ?
|
|
|
|
|
Not two control variables for one editbox ofcourse...
two boxes..
|
|
|
|
|
What error message or ASSERT do you get?
Do the controls having unqiue IDC_ values?
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
Just found the problem, it was my fault.
The problem was that after inserting a edit box and didnt save in the resource view. I was too quick too insert a control variable without saving so visual studio didnt know what to do =)
the problem was in InitInstance() on this row:
m_pMainWnd = &dlg;
Thx anyway.
These darn rc files...gah
|
|
|
|
|
Hi All!
I tried the site that peterchen suggested to me,
about displaying a bitmap (not displaying it at loading time,
but displaying it by pressing a button control), but the site was about MFC
and I don't use MFC, i use Win32 API
Can anyone tell me how can I do this?
A code would be rather usefull!
Thanks anyway \ Thanks Peterchen!
|
|
|
|
|
If you have the MFC code you normally can "translate" the MFC calls to API calls since MFC is mostly a wrapper around API functions. So if you take the MFC method of e.g. the CDC class you will find an equal (normally with the same name) API function which takes a HDC handle as parameter!
|
|
|
|
|
HBITMAP hBitmap = LoadBitmap(hInstance,"resorce name"));
BITMAP bmInfo;
GetObject(hBitmap, sizeof(BITMAP), &bmInfo);
HDC hdc = GetDC();
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP *pOldBitmap = SelectObject(hdcMem,hBitmap);
BitBlt(hdc,x,y,bmInfo.bmWidth,bmInfo.bmHeight,hdcMem,0,0,SRCCOPY);
SelectObject(hdcMem,pOldBitamp);
DeleteObject(hBitmap);
DeleteDC(hdcMem);
ReleaseDC(hdc);
HBITMAP hBitmap = (HBITMAP)::LoadImage(
NULL, "name of file", IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE);
BITMAP bmInfo;
GetObject(hBitmap, sizeof(BITMAP), &bmInfo);
HDC hdc = GetDC();
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP *pOldBitmap = SelectObject(hdcMem,hBitmap);
BitBlt(hdc,x,y,bmInfo.bmWidth,bmInfo.bmHeight,hdcMem,0,0,SRCCOPY);
SelectObject(hdcMem,pOldBitamp);
DeleteObject(hBitmap);
DeleteDC(hdcMem);
ReleaseDC(hdc);
Good luck!
INTP
|
|
|
|
|
How can I get the program below to reject anything but numbers when the program requests a number?
//Calculator program
#include <iostream>
using namespace std;
int main ()
{ long double var1;
long double var2;
char sign;
//Begin calculator loop. Will loop continuously until first
//number entered is a 0.
do {
cout << "Enter a number ";
cin >> var1;
cout << "Enter a sign ";
cin >> sign;
cout << "Enter a number ";
cin >> var2;
//The function that rejects anything but numbers here
//Begin calculator functions. +, -, /, *.
switch (sign){
case ('+'):
cout << var1 + var2 << '\n' << '\n';
break;
case ('-'):
cout << var1 - var2 << '\n' << '\n';
break;
case ('*'):
cout << var1 * var2 << '\n' << '\n';
break;
case ('/'):
cout << var1 / var2 << '\n' << '\n';
break;
default:
cout << "You didn't enter a correct sign";
cout << '\n' << '\n';
break;
//If the user enters an unrecognized sign they will get a
//message that says: You ddn't enter a correct sign.
}
} while (var1 != 0); //If first number entered is a 0
//the program will terminate at the end
//of the loop. (The Do While loop)
}
|
|
|
|
|
int var;
cin >> var;
if (cin.fail())
cout << "Not a number!" << endl;
Robert-Antonio
"CRAY is the only computer, which runs an endless loop in just 4 hours"
|
|
|
|
|
What I'm trying to do, is to pass a 2-dimensional array as an argument to a function. In one trial and error case, I was able to get a clean compile, but the program crashed when run. In another case, the program produced one compile error stating that the subscript required an array or pointer type.
My feeling is that the one compile error is more like the truth. Here's the code.
short limit = ReadThisLevel( (&tree)[SZ][SZ] );
...
short ReadThisLevel(short* tree)
{
short i, j;
for(i=0, lim=0; i<lmt; ++i)
{
for(j=0; j<SZ; ++j)
{
node = tree[i][j];
}
}
return lim;
} Leaving the code the way it is (as shown in the sample here), but make the following change to that one line, produced this other compiler message, "illegal indirection"
node = *(*(tree+i)+j); FWIW, 'tree' is defined as:
short tree[SZ][SZ]; // SZ is of type 'const short'
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
WREY wrote:
// passing an array this way allows you to pass the size of it
short limit = ReadThisLevel( (&tree)[SZ][SZ] );
No it doesn't. This won't do anything like you're wanting to do. To get your program to compile properly, declare the parameter as "short** tree " and just pass "tree " to it.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks for replying.
What you suggested, was one of several things I had tried prior to posting the question, and was one of the many results that produced a compile error (of one kind or another). (Take my word for it, I tried many different things, including the use of numbers to depict the size of the array.)
Lets give the size of the array (for simplicity sake) a size of 5. The compile error would then read, "cannot convert parameter 1 from 'short [5][5]' to 'short ** '." (That's the error received from trying your suggestion, which I myself had tried long before.)
With regards to your reason why the compiler would never do what I'm trying to accomplish, I have narrowed it down to one of three reasons. But before I get to what they are, allow me to point you to Lippman's "C++ Primer: 3rd Ed." page 348, first line (second sentence) where he states, "When the parameter is a reference to an array type, the array size becomes part of the parameter and argument types, and the compiler checks that the size of the array argument matches the one specified in the function parameter type." He then proceeds to give two examples: one correct and the other, incorrect (for the reader to understand what he's talking about).
Notice also, the compiler did not complain about the way I was passing that kind of parameter and argument. It complained about the way it was being accessed in the "called" function, which brings me around to one of my three reasons why I believe I'm not getting a clean compile.
1. I cannot pass multi-dimensional arrays (of ANY size) this way.
2. The compiler I'm using is out of compliance with the Standard.
3. Lippman is wrong.
Because I've had problems before with this compiler (MS VC6) being out of compliance with the Standard, that suspicion is very plausible. However, in this instance, I more tend to believe it's reason #1.
Bottom line: What you suggested did not work either.
Thanks anyway. I appreciate the suggestion.
William
Fortes in fide et opere!
|
|
|
|
|
Is there a way to get the red,green,blue of a specified pixel in MFC? I have been trying to figure this out for awile, so I'm guessing its not easy? Any help is appreciated.
-Dev578
|
|
|
|
|
Yes - if I get what you mean. You have a value of type RGB and you want to get the reg green and blue values from it?
You have the GetRValue, GetGValue and GetBValue functions that will extract the values from it.
|
|
|
|
|
Sorry, I may have worded the question badly. I am trying to get the RGB values from a pixel on the screen. I'm guessing I need to use the "GetPixel(HDC,int,int);" function. I know that the two int's are x and y. What is HDC? Any help would be appreciated.
-Dev578
|
|
|
|
|
Dev578 wrote:
What is HDC?
The handle of the Device Context your trying to get a value from.
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
If your not sure what an HDC is then your in for a rough ride in windows programming.
An HDC is a handle to interact with a display surface (e.g. the screen). Every window has an HDC which you can get by using
HDC hdc = ::GetDC(HWND);
... use the hdc
ReleaseDC(HWND, hdc);
HWND, is the handle for the window you want to access the HDC of. In your case, you want to get a pixel colour on the screen. You can pass NULL as the HWND to return the HDC of the entire screem:
HDC hdcScreen = ::GetDC(NULL);
COLORREF = col = ::GetPixel(hdcScreen, x, y);
::ReleaseDC(NULL, hdcScreen);
You can then extract the individual RGB values from the COLORREF returned.
When working with HDCs, make sure you return them in the same state to the OS that you got them in (i.e. use SaveDC()/RestoreDC()), and please make sure that any you Get, you release otherwise as your program runs, it will slowely consume all available drawing resources, until at some point, windows will run out and start giving you very eratic behaviour.
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|