|
could you eloborate you problem or mail me at thatsalok@gmail.com
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Mr Bose Dayala wrote:
can anybody gimme the program with code to create a anolog clock.
Probably, but nobody will. Why don't you write it yourself and if you run into any problems, ask a question about how to do a particular thing. You're much more likely to get a useful response that way.
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"
|
|
|
|
|
I found one some months ago here on CP. have you looked here in the articles?
besides I don't think it should be so dificult to make.
think of what parts a clock consists (circle, lines, pointers,...) All of them are static accept the pointers, the base is static (center of the circle) while the point moves, it moves (for the seconds) 360/60 of the circle every second.
The only thing you need to do is to redraw this pointer every second on the right place.
Just know your geometry.;)
hope this helps...
[EDIT]
Oh by the way, I did analog meters for a car once, which worked perfectly, the one thing you may want to consider is buffering to reduce flicker. I did it as described above, but I don't have the code anymore
[/EDIT]
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I am calling Form2 from Form1, and depending on the input in Form2, I want to enable/disable buttons in Form1 when I exit. However, because I need to call Form2 header before I define class Form1, Form1 is not defined when the compiler sees my call to it. If I therefore call Form1 header in Form2 header, then the compiler will see my call to Form2 before Form2 is defined!!.
Basically therefore, I wanna be able to call each form from each form, but have to define and make the call in one first.
This seems to me a very obvious thing to want to do, but I can't figure out myself how to do it, as you can't declare an extern class, or see any examples on the net of how to do it in Visual C++.net.
Any help appreciated, as is a real stumbling block for me.
UltimateNewbie
|
|
|
|
|
Hi,
In any case one form will be the parent of the other form. So in the 2nd form use the GetParent() function to get the pointer cast it to the parent parentclass, set the parent's values using the currently got value
Have a look @ the following code,
CParentDlg *pParent = (CParentDlg *) GetParent();
pParent->m_iNewValue = m_iGotValue;
Hope this will help you.
Sujan
|
|
|
|
|
Your question is a little confusing, but I think you need to a forward declaration of one of your classes.
class Form1; in your Form2.h
or
class Form2; in your Form1.h
A lot depends on how the classes are referencing each other.
Michael
CP Blog [^]
|
|
|
|
|
Hi
I am creating a class derived from CListBox so I can control the fonts, color, etc2. I also want to control the background color of the listbox (not the text's background color, but the whole listbox' background color), and I am doing it by handling WM_ERASEBKGND message in OnEraseBkgnd() function.
The OnEraseBkgnd() implementation is very simple, basically I just obtain the client rect and the use CDC::FillSolidRect to fill it with the background color of my choice.
The problem is, the background color is correctly drawn if there is at least one item in the listbox, but when the listbox is empty, the background color is always displayed as white, even though I have stepped in the debugger and make sure that the FillSolidRect function is executed.
Could someone tell me what the possible cause for this is? Thanks!
|
|
|
|
|
Hi
this is from MSDN :
<br />
The WM_CTLCOLORLISTBOX message is sent to the parent window of a list box before the system draws the list box. By responding to this message, the parent window can set the text and background colors of the list box by using the specified display device context handle.<br />
|
|
|
|
|
Are you calling the base class OnEraseBkgnd() ?
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)
|
|
|
|
|
I need to make my application non-resizable. how do i do that?
Single Doc Interface, CFormView (all set up through MFC App Wizard).
|
|
|
|
|
Hi,
Add the following code to CMainFrame's PreCreateWindow
cs.style = WS_OVERLAPPED | WS_SYSMENU | WS_BORDER;
Sujan
|
|
|
|
|
Hello, I'm creating a program that displays a menu to the user and gives the user the option to open the following programs:
1. Freecell
2. Minesweeper
3. Paint
4. Quit
It does open the programs correctly but when the user enters 4 for quit, I want my program to close all of the programs the user opened. I am not sure how to do that though. I have created a function called ExitProcess and have a call to it when the user enters 4 as their choice. There is no code in that function.
Here is most of the code:
#include <iostream.h><br />
#include <windows.h><br />
#include <string.h><br />
#include <stdio.h><br />
<br />
void DisplayMenu();<br />
void CreateProcess(int option);<br />
void ExitProcess(void);<br />
void main()<br />
{<br />
DisplayMenu();<br />
<br />
return;<br />
}<br />
<br />
void DisplayMenu()<br />
{<br />
int option;<br />
<br />
<br />
cout << "\n\nPlease type your choice "<br />
<< "and press the return key : ";<br />
<br />
cin >> option;<br />
CreateProcess(option);<br />
<br />
return;<br />
}<br />
<br />
void CreateProcess(int option)<br />
{<br />
STARTUPINFO si;<br />
PROCESS_INFORMATION pi; <br />
<br />
ZeroMemory( &si, sizeof(si) );<br />
si.cb = sizeof(si); <br />
ZeroMemory( &pi, sizeof(pi) ); <br />
<br />
switch (option)<br />
{<br />
case 1 : if( !CreateProcess( NULL, <br />
"C://FreeCell.exe",NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi)) <br />
{<br />
ExitProcess(1);<br />
} <br />
system("cls");<br />
DisplayMenu();<br />
<br />
break; <br />
<br />
case 2 : if( !CreateProcess( NULL, <br />
"winmine.exe",NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi)) <br />
{<br />
ExitProcess(1);<br />
} <br />
system("cls");<br />
DisplayMenu();<br />
<br />
break;<br />
<br />
case 3 : if( !CreateProcess( NULL, <br />
"MsPaint.exe",NULL,NULL,FALSE, NULL,NULL,NULL,&si,&pi )) <br />
{<br />
ExitProcess(1);<br />
} <br />
<br />
system("cls");<br />
DisplayMenu();<br />
<br />
break;<br />
<br />
<br />
<br />
case 4 : WaitForSingleObject( pi.hProcess, INFINITE );<br />
ExitProcess();<br />
CloseHandle( pi.hProcess );<br />
CloseHandle( pi.hThread );<br />
<br />
exit(100);<br />
<br />
break;<br />
<br />
<br />
default : cout << "\a\aOption Not Available\n";<br />
system("cls");<br />
DisplayMenu();<br />
}<br />
<br />
return;<br />
}<br />
void ExitProcess(void)<br />
{<br />
<br />
}
|
|
|
|
|
Send WM_QUIT message to each running application.
PROCESS_INFORMATION pi[3];
STARTUPINFO si[3];
ZeroMemory( &si[0], sizeof(si[0]) );
si.cb = sizeof(si[0]);
ZeroMemory( &pi[0], sizeof(pi[0]) );
ZeroMemory( &si[1], sizeof(si[1]) );
si.cb = sizeof(si[1]);
ZeroMemory( &pi[1], sizeof(pi[1]) );
ZeroMemory( &si[2], sizeof(si[2]) );
si.cb = sizeof(si[2]);
ZeroMemory( &pi[2], sizeof(pi[2]) );
if(pi[0].hProcess==NULL)
CreateProcess( NULL, "C://FreeCell.exe",NULL,NULL,FALSE,NULL,NULL,NULL,&si[0],&pi[0]));
if(pi[1].hProcess==NULL)
CreateProcess( NULL, "winmine.exe",NULL,NULL,FALSE,NULL,NULL,NULL,&si[1],&pi[1]);
if(pi[2].hProcess==NULL)
CreateProcess( NULL, "MsPaint.exe",NULL,NULL,FALSE, NULL,NULL,NULL,&si[2],&pi[2]);
if(pi[0].hProcess)
::PostThreadMessage(pi[0].dwThreadId,WM_QUIT,0,0);
if(pi[1].hProcess)
::PostThreadMessage(pi[1].dwThreadId,WM_QUIT,0,0);
if(pi[2].hProcess)
::PostThreadMessage(pi[2].dwThreadId,WM_QUIT,0,0);
CloseHandle( pi[0].hProcess );
CloseHandle( pi[0].hThread );
CloseHandle( pi[1].hProcess );
CloseHandle( pi[1].hThread );
CloseHandle( pi[2].hProcess );
CloseHandle( pi[2].hThread );
Regards,
Andrzej Markowski
|
|
|
|
|
Enumerate All Windows on specified thread. Post WM_CLOSE to them , in order to close the application in safe manner.Later u may call terminateprocess API
|
|
|
|
|
Thanks for the reply.
I am getting an 3 errors which say "left of .cb must have class/struct/union type".
This is the part of the code it is giving those errors:
<br />
PROCESS_INFORMATION pi[3];
STARTUPINFO si[3];
ZeroMemory( &si[0], sizeof(si[0]) );<br />
ZeroMemory( &pi[0], sizeof(pi[0]) ); <br />
ZeroMemory( &si[1], sizeof(si[1]) );<br />
ZeroMemory( &pi[1], sizeof(pi[1]) ); <br />
ZeroMemory( &si[2], sizeof(si[2]) );<br />
|
|
|
|
|
Change the code like this:
PROCESS_INFORMATION pi[3];
STARTUPINFO si[3];
ZeroMemory( &si[0], sizeof(STARTUPINFO));<br />
si[0].cb = sizeof(STARTUPINFO); <br />
ZeroMemory( &pi[0], sizeof(PROCESS_INFORMATION)); <br />
ZeroMemory( &si[1], sizeof(STARTUPINFO));<br />
si[1].cb = sizeof(STARTUPINFO); <br />
ZeroMemory( &pi[1], sizeof(PROCESS_INFORMATION)); <br />
ZeroMemory( &si[2], sizeof(STARTUPINFO));<br />
si[2].cb = sizeof(STARTUPINFO); <br />
ZeroMemory( &pi[2], sizeof(PROCESS_INFORMATION));
Regards,
Andrzej Markowski
|
|
|
|
|
Thanks for the help Andrzej
I have configured the code as shown below: Including a couple of functions. The program builds with 0 errors and 0 warnings, but for some reason when I enter a choice like (1) for "Freecell", my program quits, the program that I have opened remains open, so I do not have the chance to quit the Freecell program. Not sure why it is not giving me another choice:
#include <iostream.h><br />
#include <windows.h><br />
#include <string.h><br />
#include <stdio.h><br />
<br />
void DisplayMenu();<br />
void process(int option);<br />
<br />
<br />
void main()<br />
{<br />
DisplayMenu();<br />
return;<br />
}<br />
<br />
void DisplayMenu()<br />
{<br />
int option;<br />
<br />
cout << "\n\n\n";<br />
cout << "\n\t*********************************";<br />
cout << "\n\t* *";<br />
cout << "\n\t* MENU *";<br />
cout << "\n\t* *";<br />
cout << "\n\t* 1. FreeCell *";<br />
cout << "\n\t* 2. MineSweeper *";<br />
cout << "\n\t* 3. Paint *";<br />
cout << "\n\t* 4. Quit *";<br />
cout << "\n\t* *";<br />
cout << "\n\t*********************************";<br />
<br />
cout << "\n\nPlease type your choice "<br />
<< "and press the return key : ";<br />
<br />
cin >> option;<br />
process(option);<br />
<br />
return;<br />
}<br />
<br />
void process(int option)<br />
{<br />
<br />
STARTUPINFO si[3];<br />
PROCESS_INFORMATION pi[3]; <br />
int i=0;<br />
<br />
ZeroMemory( &si[0], sizeof(si[0]) );<br />
si[0].cb = sizeof(si[0]); <br />
ZeroMemory( &pi[0], sizeof(pi[0]) ); <br />
<br />
ZeroMemory( &si[1], sizeof(si[1]) );<br />
si[1].cb = sizeof(si[1]); <br />
ZeroMemory( &pi[1], sizeof(pi[1]) ); <br />
<br />
ZeroMemory( &si[2], sizeof(si[2]) );<br />
si[2].cb = sizeof(si[2]); <br />
ZeroMemory( &pi[2], sizeof(pi[2]) ); <br />
<br />
switch (option)<br />
{<br />
case 1 : if(pi[0].hProcess==NULL)CreateProcess( NULL, <br />
"FreeCell.exe", <br />
NULL, <br />
NULL, <br />
FALSE, <br />
NULL, <br />
NULL, <br />
NULL, <br />
&si[0], <br />
&pi[0]); <br />
<br />
{<br />
ExitProcess(1);<br />
} <br />
<br />
<br />
system("cls");<br />
DisplayMenu();<br />
<br />
break; <br />
<br />
case 2 : if(pi[1].hProcess==NULL)CreateProcess( NULL, <br />
"winmine.exe", <br />
NULL, <br />
NULL, <br />
FALSE, <br />
NULL, <br />
NULL, <br />
NULL, <br />
&si[1], <br />
&pi[1]); <br />
<br />
{<br />
ExitProcess(1);<br />
} <br />
<br />
<br />
system("cls");<br />
DisplayMenu();<br />
<br />
break;<br />
<br />
case 3 : if(pi[2].hProcess==NULL)CreateProcess( NULL, <br />
"MsPaint.exe",
NULL, <br />
NULL, <br />
FALSE, <br />
NULL, <br />
NULL, <br />
NULL, <br />
&si[2], <br />
&pi[2]); <br />
<br />
{<br />
ExitProcess(1);<br />
} <br />
<br />
system("cls");<br />
DisplayMenu();<br />
<br />
break;<br />
<br />
<br />
<br />
case 4 : if(pi[0].hProcess)::PostThreadMessage(pi[0].dwThreadId,WM_QUIT,0,0);<br />
if(pi[1].hProcess)::PostThreadMessage(pi[1].dwThreadId,WM_QUIT,0,0);<br />
if(pi[2].hProcess)::PostThreadMessage(pi[2].dwThreadId,WM_QUIT,0,0);<br />
CloseHandle( pi[0].hProcess );<br />
CloseHandle( pi[0].hThread );<br />
CloseHandle( pi[1].hProcess );<br />
CloseHandle( pi[1].hThread );<br />
CloseHandle( pi[2].hProcess );<br />
CloseHandle( pi[2].hThread );<br />
exit(100);<br />
<br />
break;<br />
<br />
default : printf("\a\aOption Not Available\n");<br />
system("cls");<br />
DisplayMenu();<br />
}<br />
<br />
return;<br />
}
|
|
|
|
|
You should declare the arrays (si and pi ) as global variables. Also you can't call the DisplayMenu from within the process function (recursion).
Here's an example how to fix these problems:
STARTUPINFO si[3];
PROCESS_INFORMATION pi[3];
int DisplayMenu();
void process(int option);
void main()
{
ZeroMemory( &si[0], sizeof(si[0]) );
si[0].cb = sizeof(si[0]);
ZeroMemory( &pi[0], sizeof(pi[0]) );
ZeroMemory( &si[1], sizeof(si[1]) );
si[1].cb = sizeof(si[1]);
ZeroMemory( &pi[1], sizeof(pi[1]) );
ZeroMemory( &si[2], sizeof(si[2]) );
si[2].cb = sizeof(si[2]);
ZeroMemory( &pi[2], sizeof(pi[2]) );
while(DisplayMenu()!=4)
return;
}
int DisplayMenu()
{
int option;
system("cls");
cout << "\n\n\n";
cout << "\n\t*********************************";
cout << "\n\t* *";
cout << "\n\t* MENU *";
cout << "\n\t* *";
cout << "\n\t* 1. FreeCell *";
cout << "\n\t* 2. MineSweeper *";
cout << "\n\t* 3. Paint *";
cout << "\n\t* 4. Quit *";
cout << "\n\t* *";
cout << "\n\t*********************************";
cout << "\n\nPlease type your choice "
<< "and press the return key : ";
cin >> option;
process(option);
return option;
}
void process(int option)
{
switch (option)
{
case 1 : if(pi[0].hProcess==NULL)CreateProcess( NULL,
"FreeCell.exe",
NULL,
NULL,
FALSE,
NULL,
NULL,
NULL,
&si[0],
&pi[0]);
break;
case 2 : if(pi[1].hProcess==NULL)CreateProcess( NULL,
"winmine.exe",
NULL,
NULL,
FALSE,
NULL,
NULL,
NULL,
&si[1],
&pi[1]);
break;
case 3 : if(pi[2].hProcess==NULL)CreateProcess( NULL,
"MsPaint.exe",
NULL,
NULL,
FALSE,
NULL,
NULL,
NULL,
&si[2],
&pi[2]);
break;
case 4 : if(pi[0].hProcess)::PostThreadMessage(pi[0].dwThreadId,WM_QUIT,0,0);
if(pi[1].hProcess)::PostThreadMessage(pi[1].dwThreadId,WM_QUIT,0,0);
if(pi[2].hProcess)::PostThreadMessage(pi[2].dwThreadId,WM_QUIT,0,0);
CloseHandle( pi[0].hProcess );
CloseHandle( pi[0].hThread );
CloseHandle( pi[1].hProcess );
CloseHandle( pi[1].hThread );
CloseHandle( pi[2].hProcess );
CloseHandle( pi[2].hThread );
break;
default : printf("\a\aOption Not Available\n");
break;
}
return;
}
Regards,
Andrzej Markowski
|
|
|
|
|
Finally got it!
Thanks for all the help
|
|
|
|
|
Again thanks for the help Andrzej, I have pretty much configured the program to work how I want except for one thing.
I want to be able to open more than one of the same program. So if I open one Paint program I want to be able to enter 3 again for Paint and have it open another. It only lets me open one of each right now.
Is there anyway to work around it? Meaning can I keep the global variables or is that one of the things that is preventing me from opening more than one program?
Thanks again.
|
|
|
|
|
Just want to clarify something...
I know how to be able to open more than one program but I'm not sure how to let the computer keep track of them so it closes them all.
When I do change it to open more than one program and I enter 4 to close them it does not close any of them.
|
|
|
|
|
Your program has to save the ThreadId for each new created process. Later the ThreadId is passed as the parameter to the PostThreadMessage function which is called to close the program the user opened. The modified example saves this information in the rp array of RUNNING_PROCESS_INFO structures. The nRPCounter specifies a number of currently running processes and also is the next avaliable index in the rp table. When the process is created a space for the RUNNING_PROCESS_INFO structure is allocated at the and of the array and the nRPCounter is incremented. When the user closes the program the counter is decremented and the structures in the array located below deleted item are moved one item up.
#include stdio.h
#include process.h
#include iostream.h
#include time.h
#include windows.h
typedef struct
{
DWORD dwThreadId;
BYTE bProcessType;
} RUNNING_PROCESS_INFO;
#define MAX_PROCESSES 10
RUNNING_PROCESS_INFO rp[MAX_PROCESSES];
int nRPCounter = 0;
int DisplayMainMenu();
void DisplayStopProcessMenu();
void process(int option);
int main(int argc, char* argv[])
{
while(DisplayMainMenu()!=5);
return 0;
}
int DisplayMainMenu()
{
int option=0;
system("cls");
cout << "\n\n\n";
cout << "\n\t*********************************";
cout << "\n\t* *";
cout << "\n\t* MAIN MENU *";
cout << "\n\t* *";
cout << "\n\t* 1. FreeCell *";
cout << "\n\t* 2. MineSweeper *";
cout << "\n\t* 3. Paint *";
cout << "\n\t* 4. StopProcess *";
cout << "\n\t* 5. Quit *";
cout << "\n\t* *";
cout << "\n\t*********************************";
cout << "\n\nPlease type your choice "<< "and press the return key : ";
cin >> option;
process(option);
return option;
}
void DisplayStopProcessMenu()
{
int option=0;
system("cls");
cout << "\n\n\n";
cout << "\n\t*********************************";
cout << "\n\t* *";
cout << "\n\t* STOP PROCESS MENU *";
cout << "\n\t* *";
for(int i=0;i<nRPCounter;i++)
{
cout << "\n\t* ";
cout << i+1;
cout << ". ";
if(rp[i].bProcessType==1)
cout << "FreeCell *";
else if(rp[i].bProcessType==2)
cout << "MineSweeper *";
else
cout << "Paint *";
}
cout << "\n\t* *";
cout << "\n\t*********************************";
cout << "\n\nPlease type your choice "<< "and press the return key : ";
cin >> option;
if(option>=1 && option<=nRPCounter)
{
PostThreadMessage(rp[option-1].dwThreadId,WM_QUIT,0,0);
nRPCounter--;
for(int i=option-1; i<nRPCounter; i++)
memcpy(&rp[i],&rp[i+1],sizeof(RUNNING_PROCESS_INFO));
}
}
void process(int option)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
if(option>=1 && option<=3)
{
if(nRPCounter==MAX_PROCESSES)
{
printf("\a\aRunning processes table full\n");
return;
}
ZeroMemory( &pi, sizeof(PROCESS_INFORMATION) );
ZeroMemory( &si, sizeof(STARTUPINFO) );
si.cb = sizeof(STARTUPINFO);
}
switch (option)
{
case 1 :
if(CreateProcess( NULL, "FreeCell.exe", NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi))
{
rp[nRPCounter].dwThreadId = pi.dwThreadId;
rp[nRPCounter++].bProcessType = 1;
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
else
printf("\a\aCreateProcess(...) failed\n");
break;
case 2 :
if(CreateProcess( NULL, "winmine.exe", NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi))
{
rp[nRPCounter].dwThreadId = pi.dwThreadId;
rp[nRPCounter++].bProcessType = 2;
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
else
printf("\a\aCreateProcess(...) failed\n");
break;
case 3 :
if(CreateProcess( NULL, "MsPaint.exe", NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi))
{
rp[nRPCounter].dwThreadId = pi.dwThreadId;
rp[nRPCounter++].bProcessType = 3;
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
else
printf("\a\aCreateProcess(...) failed\n");
break;
case 4:
DisplayStopProcessMenu();
break;
case 5 :
{
for(int i=0; i<nRPCounter;i++)
PostThreadMessage(rp[i].dwThreadId,WM_QUIT,0,0);
}
break;
default :
printf("\a\aOption Not Available\n");
break;
}
}
Regards,
Andrzej Markowski
|
|
|
|
|
Very Important!!!!
Don't use WM_QUIT message to kill other processes. Instead of WM_QUIT use WM_CLOSE. If you send WM_QUIT the application will not clean up resources and you will have memory leaks.
Regards,
Andrzej Markowski
|
|
|
|
|
Posting WM_CLOSE message to the main thread using PostThreadMessage doesn't close your application also. You have to post WM_CLOSE message to all windows on the main thread, as vikrams said. Here's the code how to do this :
BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM lParam)
{
::PostMessage(hwnd,WM_CLOSE,0,0);
return TRUE;
}
EnumThreadWindows(rp[option-1].dwThreadId,EnumThreadWndProc,0); Regards,
Andrzej Markowski
|
|
|
|
|
I´m trying to use the IDirectDrawSurface::AlphaBlt method in wince.
Then I have to create an alpha surface and blit that surface to a "normal" (not an alpha surface) surface with the AlphaBlt method, I think....
But when I try to create an alpha surface,I get an invalid parameter as a result!
Is there anybody that has a clue to this error?
These are important flags for the DDPIXELFORMAT in wince:
DDPF_ALPHA: The pixel format describes an alpha-only surface.
DDPF_ALPHAPIXELS: The surface has alpha channel information in the pixel format.
DDPF_ALPHAPREMULT: The color components in the pixel are premultiplied by the alpha value in the pixel. If this flag is set, the DDPF_ALPHAPIXELS flag must also be set. If this flag is not set but the DDPF_ALPHAPIXELS flag is set, the color components in the pixel format are not premultiplied by alpha. In this case, the color components must be multiplied by the alpha value at the time that an alpha-blending operation is performed.
DDPF_RGB: The RGB data in the pixel format structure is valid.
I think I should only use the DDPF_ALPHA and DDPF_RGB flags but I am not sure?
Any comments?
I don´t think I should specify any alphabitdepth as there is no alpha channel information in the RGB_565 pixelformat,isn´t that right?
This is how the code looks like:
Globals:
<br />
LPDIRECTDRAW4 lpDD4;<br />
LPDIRECTDRAWSURFACE4 lpddsurf;<br />
SIZE size;<br />
<br />
size.cx=486;<br />
size.cy=274;<br />
<br />
CreateAlphaSurface(&lpddsurf,&size); <br />
<br />
int CreateAlphaSurface( LPDIRECTDRAWSURFACE4* lplpDDS,LPSIZE lpSize )<br />
{<br />
DDSURFACEDESC2 ddsd;<br />
HRESULT res;<br />
<br />
ZeroMemory( &ddsd, sizeof ddsd );<br />
ddsd.dwSize = sizeof ddsd;<br />
<br />
ddsd.dwFlags=DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT;<br />
<br />
ddsd.ddsCaps.dwCaps =DDSCAPS_ALPHA;<br />
ddsd.ddpfPixelFormat.dwRBitMask=0xf800;<br />
ddsd.ddpfPixelFormat.dwGBitMask=0x07e0;<br />
ddsd.ddpfPixelFormat.dwBBitMask=0x001f;<br />
ddsd.ddpfPixelFormat.dwRGBBitCount=16;<br />
ddsd.ddpfPixelFormat.dwFlags=DDPF_ALPHA|DDPF_RGB;<br />
ddsd.dwWidth = lpSize->cx;<br />
ddsd.dwHeight = lpSize->cy;<br />
<br />
<br />
res=lpDD4->CreateSurface(&ddsd,lplpDDS,NULL);<br />
if(res!=DD_OK) <br />
MessageBox(NULL,L"CreateSurface didn´t worked",NULL,NULL);<br />
<br />
switch(res){<br />
case DDERR_INVALIDPARAMS:<br />
MessageBox(NULL,L"CreateSurface INVALIDPARAMS",NULL,NULL);<br />
break;<br />
case DDERR_INVALIDOBJECT:<br />
MessageBox(NULL,L"CreateSurface INVALIDOBJECT",NULL,NULL);<br />
break;<br />
case DDERR_SURFACEBUSY:<br />
MessageBox(NULL,L"CreateSurface SURFACEBUSY",NULL,NULL);<br />
break;<br />
}<br />
}<br />
<br />
return 0;<br />
}
Please help anyone, I cannot understand what is wrong, it has to be something with the flags?
Thanks for your help!
|
|
|
|
|