|
I believe DirectDraw isn't officially supported since DX8. That means you still can use it, but you won't find documentation for it (last is in DX7 SDK I believe). Make sure you're on WXP as AFAIK that's what DX10 needs.
Also, I believe LPDIRECTDRAW4 is surely older interface than necessary, try LPDIRECTDRAW7 or LPDIRECTDRAW6.
As for setting up VC 6.0: set up the prober include and library directories as you did. Move them both to the top of the list! Otherwise, it won't work (at least with DX8 I've been using). You also need to link some libs... like ddraw.lib and maybe dxguid.lib, depending on what parts of DX you use (look in the libs directory and use common sense).
I believe you should better use D3D to draw graphics. As for links, gamedev.net has some nice articles and good forums for this kind of stuff (in the forum FAQ for D3D, you can even find links to some page that has older SDK for download if you want DD documentation). A nice tutorial is at http://www.andypike.com/tutorials/ . If you just want to do 2D with D3D, look up Sprites in the SDK. Also, there are some nice tutorials in the SDK's help files.
Haven't touched DX since DX8/9, so if there's something new specifically to DX10, sorry
|
|
|
|
|
Thanks very much indeed - moving the includes to the top of the list did the trick. Maybe in years to come I'll understand exactly what the linker is doing, when & why....
And thanks for all the other tips. I'm only using LPDIRECTDRAW4 because I'm cutting and pasting samples from an old Andre Lamothe book (Tricks of the Windows Game Programming Gurus). I'll try updating it and thanks too for the link.
|
|
|
|
|
Could any tell me how I display a float value in a message box.
Your result is: 1234567.5678 - for example
Many Thanks
Steve
|
|
|
|
|
I think you use to convert Numeric to String
Example:
int a=123;
TCHAR Buffer[50];
itoa(a,Buffer,10);
MessageBox(Buffer);But if you use 123.23->result 123
|
|
|
|
|
WhiteSky wrote: Example:int a=123;TCHAR Buffer[50];itoa(a,Buffer,10);MessageBox(Buffer);But if you use 123.23->result 123
what about CString::Format or wsprintf command
|
|
|
|
|
|
I need to get it in to the message box.
Cheers
Steve
|
|
|
|
|
char convert[20];
double Number = 1.123;
_gcvt( Number, 4, convert);
MessageBox(convert);
|
|
|
|
|
we're not on the managed forum
|
|
|
|
|
v2.0 wrote: we're not on the managed forum
_gcvt is a native CRT function.
Regards,
Nish
|
|
|
|
|
oh, don't know why, but i think the prefixing _gc made me wrong :->
|
|
|
|
|
Steve Kelly wrote: I need to get it in to the message box.
TCHAR szString[150];
wsprintf(szString,_T("Your Result is :- %f"),dResult);
AfxMessageBox(szString);
|
|
|
|
|
Good solution.
I'd go for this type of simple, direct solution as well, but using sprintf() and MessageBox() (I still think in Ascii and C)!
|
|
|
|
|
CString szCaption;
float fResult = 14.58;
szCaption.Format("%f" , fResult);
AfxMessageBox(szCaption);
Regards,
Eli
|
|
|
|
|
Hi all,
I have a splitter window with two list views horizontally.
My aim is to drag an EXE file and drop it in the top view. I have implemented the required drag & drop operations in the top view. Everything works fine. But I need to disable drag & drop in bottom list view. If I try to drop in the bottom view, nothing should happen. How can I achieve this. Give me your hands, please.
Thanks in advance,
Sarvan AL
-- modified at 1:54 Sunday 26th March, 2006
|
|
|
|
|
|
Hi, 1st post here
I'm trying to figure out the address where the threads of a program are currently executing. This is the code of the internal loop:
<br />
CONTEXT Context;<br />
ZeroMemory(&Context,sizeof(Context));<br />
Context.ContextFlags=CONTEXT_CONTROL|CONTEXT_INTEGER;<br />
<br />
HANDLE h=OpenT(process.NtProcess->Threads[i].id);
SuspendThread(h);<br />
GetThreadContext(h,&Context);<br />
ResumeThread(h);<br />
CloseHandle(h);<br />
All the above works fine. The problem is that for all the threads I get the same Context.Eip
Anyway, do you know a simple and better way, so that my head doesn't explode?
Thanks all!
|
|
|
|
|
Hi,
I am facing a peculiar problem. I am using Visual C++ for a program which reads the serial port continously. I am using a "while" loop for this. But after starting the program I am not able to do anything with the application window (lik minimize, maximize, or stop the program). Can anybody help me in tackling this problem.
With thanks in advance.
VKA
|
|
|
|
|
You need to have a separate thread for lengthy operations. Either that or you can pump window messages in the while loop, but that's not really recommended as it's a bad design.
|
|
|
|
|
Hi hfry,
Thanks for the reply. But Can youp please tell me how to use separate thread?
On the second point do you mean show message option with YES NO click buttons or some thing else?
I am new to programming. That is why I am not getting the terminology.
Thanks
vka
|
|
|
|
|
You create threads with the C function _beginthreadex, unless you are absolutely sure you are not using any CRT functions, in which case you can use CreateThread. You then need various ways of sending information from your main thread to the worker thread and vice versa. You can use events and have the thread wait for events to be signalled, or you could have the worker thread have its own message queue and pass messages using PostThreadMessage. I find the easiest way for the thread to send messages to the main thread is to just use SendMessage. This really all boils down to your requirements. Is there any particular reason why you aren't using asynchronous i/o? Did you check out any of the articles on Code Project?
Regarding sleeping in your loop: Sleep won't help your application respond. The reason it doesn't respond is because you are performing a lengthy operation in your main thread. The main thread never gets to get the next message in the message queue to handle. If you don't know what a message loop is or what windows messages are, it's time to go find a tutorial online.
You pump messages by having a function that looks something like this (this is not the recommended method of solving your problem)
<br />
void PumpMessages()<br />
{<br />
MSG msg;<br />
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br />
{<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
}<br />
<br />
while(1)<br />
{<br />
DoSomething();<br />
PumpMessages();<br />
}<br />
|
|
|
|
|
You should pool the serial port, but insert small pauses on your loop like:
Sleep(10)
... and only then read it continuously. If there aren't any pauses, other programs, threads and the system itself don't have the opportunity to run properly.
|
|
|
|
|
Hi God,
How does it help in exiting the application? It is not responding to the STOP button click. If I add sleep(10), will it respond?
Thanking you,
vka
|
|
|
|
|
Oh, I see. In fact you may need 2 threads.
Let's assume your function is called "SerialPortPoolFunction"
<br />
int SerialPortPoolFunction(void *Parameter)<br />
{<br />
HANDLE Event=(HANDLE)Parameter; <br />
for ( ;; ) <br />
{<br />
<br />
int i=WaitForSingleObject(Event,10);
if (i==WAIT_OBJECT_0)
return 0; <br />
}<br />
}<br />
<br />
<br />
<br />
<br />
<br />
HANDLE hEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
<br />
DWORD id;<br />
HANDLE hThread=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SerialPortPoolFunction, <br />
(void *)hEvent, 0, &id);<br />
}<br />
When the user presses the "Stop" button, you may execute: PulseEvent(hEvent);
So the WaitForSingleObject inside the SerialPortFunction is supposed to return WAIT_OBJECT_0, because you just signaled it. And the thread returns.
Hope that I could help w/o too many bugs. At least it gives the general idea.
|
|
|
|
|
PulseEvent is flawed, http://blogs.msdn.com/oldnewthing/archive/2005/01/05/346888.aspx[^].
As it assumes that there is a thread waiting for the event, and this is impossible to determine.
Anyway it looks like the event is simply just to tell the thread to stop polling, so a call to SetEvent(hEvent) is sufficient, and since bManualReset is FALSE, it automatically clears the event.
And you really should be matching the function of SerialPortPoolFunction to LPTHREAD_START_ROUTINE instead of casting it, most win32 projects default to cdecl and LPTHREAD_START_ROUTINE is stdcall.
|
|
|
|