|
Thanks for the link Michael, I've downloaded the resource and am going to try and rip it apart to get what I need. Essentially, I'd like to do my own framework and just need a little guidance, so hopefully this will be it.
Many Thanks,
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
I have a copy of the book and I used it to build my own little DirectX framework. The book is well worth reading if you can find a copy.
Michael
Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor
|
|
|
|
|
Cheers Michael, will keep my eyes peeled for it when I'm in Waterstones or Blackwells next
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
OK, I have the following code which starts my app rolling:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCommandLine, int nCmdShow)
{
if (FAILED(InitApp(hInstance, nCmdShow)))
return 0;
//*
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
ProcessMessage(&msg);
}
return 0;
}
I have set up my own WindowProc (Fullscreen Exclusive) and initialised DirectDraw, a Primary Surface and Direct3D (global variables initialised in InitApp). OK, if I then load a bitmap into a plain offscreen surface (same res as screen), and bltfast it to the Primary Surface back buffer at the //* point and call the primary buffer flip() routine, the bitmap appears, magic. However, if I then bltfast the same picture to the backbuffer (that was the primary surface before the flip) but at a ddiferent position and then call the primary buffer flip() routine again, it is blank (sometimes I get a flicker of the picture before it goes blank). So something must be clearing the data of the primary buffer, I assume? Now for the strange things:
1.) If I set up a timer and handle it in my window proc, with the exact same code, it works, I get a small animation where the picture moves from point a to point b.
2.) Every time I start the app the initial Primary Surface gets cleared and is blank (Is this perhaps to do with my WindowClass which sets the screen to blackness - even though the primary surface hasn't been created at this point?), but the back buffer retains any previous image that was drawn into it. Yes thats right, if I eliminate all drawing code and merely flip() the Primary Surface, up comes the image I displayed in a previous debug initiation, but if I flip again its blank etc.
3.) Now for the one that will have you rocking. Assuming the bltfast code etc. is by the //* position of my code above. Insert the line MessageBox(GetActiveWindow(), "YAY", "YAY", MB_OK); at that point, but above the bltfast code, IT WORKS! You get a message box and then once you click ok, the primary surface flips a couple of times and leaves you with a beautiful bitmap (no blank surface).
If anyone can answer any of these strange problems, I would well appreciate it. I have had to buy head and shoulders shampoo cos I've scratched my head so much.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Hi,
I've got an MDI app with a ScrollView which acts strangely when I load a file with more than 2060 lines.
The problem manifests its self like this .... if I click above or below the 'Thumb' on the Vertical Scroll Bar it all works OK, but if I grab the 'Thumb' and drag it downwards it jumps back to the top of the file at around line 2060.
My code to set the ScrollView Size is like this:-
CSize sizeTotal;
// get the number of lines
CSQMDoc *thisDoc = GetDocument();
int nLines = thisDoc->GetCount();
// get the height for 1 line of text
TEXTMETRIC tm;
CDC *pDC = GetDC();
pDC->GetTextMetrics(&tm);
int nLineHeight = tm.tmHeight + tm.tmExternalLeading;
// set the size of the 'view' area
sizeTotal.cx = 400;
sizeTotal.cy = nLines * nLineHeight;
SetScrollSizes(MM_TEXT, sizeTotal);
ResizeParentToFit( );
Anyone got any ideas?
Cheers, Ali.
Ali
|
|
|
|
|
I know this kind of thing is hard to debug. Did you try to save the values of sizeTotal.cy in a text file in order to see if it is your calculation that is wrong or if it is the SetScrollSizes() that fails ?
~RaGE();
|
|
|
|
|
The scroll bars in a scroll view have a scroll range of 32767 counts.
My bet is that the line
sizeTotal.cy = nLines * nLineHeight;
With nLines being 2060 majes sizeTotal.cy > 32767 causing all the vertical scroll ranges to be come messed up.
I have seen an artile that covers how to get around this. I will try and find the reference.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Roger Allen wrote:
With nLines being 2060 majes sizeTotal.cy > 32767 causing all the vertical scroll ranges to be come messed up.
Yes, I've had a look in the debugger and it is going past 32767! So it looks very much like that is the problem.
Thanks for the article reference - I'll go and have a look.
Ali
|
|
|
|
|
OK, heres that reference.
http://codeguru.earthweb.com/doc_view/bigscroll.shtml
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
i want to develop my own dial-up networking. i am not sure where i can get help on the topic. what API's can help me
|
|
|
|
|
Look up RAS. These are the calls you will need to use. Its not really very difficult. I think there are some articles with sample code either here or on CodeGuru.com
|
|
|
|
|
Hi all,
Is it possible to allocate just the extra memory needed with the new Object[] mechanism?
What I've done is this:
ptrThings = new Thing[1000];
At some point I wish to construct 2000 Things. But instead of deleting[] ptrThings and doing new Thing[2000] can I allocate just the extra 1000 Things and append the allocated memory to ptrThings?
Thx a lot,
/Tommy
|
|
|
|
|
You need to leave the dark ages and enter the world of std::vector. I have an article here on CP if you're interested, it does exactly what you're after.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
You need to leave the dark ages
And if the thing is supposed to run on WinCE where STL are not allowed, what do you suggest ?
~RaGE();
|
|
|
|
|
My suggestion in that case would be that there's not much you can do if you're right and Windows CE does not support all of C++. You'd have to delete and recreate the array.
However, he did not say he cannot use STL, he obviously does not know it exists.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
My suggestion in that case would be that there's not much you can do if you're right and Windows CE does not support all of C++. You'd have to delete and recreate the array
OK, that´s what i do.
Christian Graus wrote:
However, he did not say he cannot use STL
Well, I have exactely the same problem, so I was wondering if there was a better way to do it than the destroy & redo method But I unhappily do not have STL
Christian Graus wrote:
he obviously does not know it exists
For sure ... but there is surely a Delphi command to do that, so that is why he asked
~RaGE();
|
|
|
|
|
Rage wrote:
Christian Graus wrote:
My suggestion in that case would be that there's not much you can do if you're right and Windows CE does not support all of C++. You'd have to delete and recreate the array
OK, that´s what i do.
As do I but the replies I get are somewhat newbieish.
Rage wrote:
For sure ... but there is surely a Delphi command to do that, so that is why he asked
Not that I know of... I quit using Delphi 5 years ago. Just recently I decided to pick up on some windows REAL programming.
Cheers,
/T
|
|
|
|
|
Christian Graus wrote:
However, he did not say he cannot use STL, he obviously does not know it exists.
I know it exists... and WTL and COM, COM+, DCOM, etc, bla, bla, bla... This is what somewhat disturbs me. There's always more than one solution to the problem. That's great you might say, well, maybe, if you're willing to spend most of the time consulting msdn and other not-up-to-date docs.
I'm coming straight out of the Unix world so please bear with me... There's obviously a reason for not teaching windows programming at college level.
But I'm not gonna fold! I've dug through a great portion of COM so STL is the next step, but much of the good'ole unix pure ansi c++ is still in my back bone so it'll take some time.
Cheers,
/Tommy
|
|
|
|
|
Tommy Svensson wrote:
But I'm not gonna fold! I've dug through a great portion of COM so STL is the next step, but much of the good'ole unix pure ansi c++ is still in my back bone so it'll take some time.
I'm sorry if my comment seemed to be putting you down - that is not what I meant. You asked how to do a resizeable array, the answer is vector ( BTW I quoted the abover because the STL *is* pure ANSI C++ ). Then someone else jumped in and said what about CE, which is not what you asked, and I pointed that out. WinCE may well be garbage, but you did not indicate that you knew vector solves your problem, and so I informed you that it does. There is ALWAYS more to learn, that is the fun part of doing this stuff !!!
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Now me also face the same problem..iwant the extra memory allocation in run time..it is urgent...if u can suggest any methos do it ...please stop the unworthy comemnts posting..so please save the codeproject...
if there is nothingto do..keep Mum...
Renjith-The CPian.
|
|
|
|
|
What is unworthy ? I TOLD him how to do it. I clarified my point.
Renjith - The CP ian wrote:
if there is nothingto do..keep Mum...
So if it can't be done I should not say so ?
You need vector. End of story. Without a class like vector to do it, you simply cannot resize an array. Even vector, if you did not reserve the space, may well resize the array as a new one internally - that's obvious. An array is a lump of continuous memory. Reserve it first, or you will probably find the space is not there.
I wonder if I should stop trying to help people, if my comments are 'unworthy' because they are not what you want to hear.....
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
I'm trying to copy a bitmap to clipboard using GDI+ here the code:
AfxGetApp()->m_pMainWnd->OpenClipboard();
EmptyClipboard();
Bitmap bitmap(pView->GetWidth(), pView->GetHeight());
HBITMAP hBitmap;
Color background(255,255,255);
bitmap.GetHBITMAP( background, &hBitmap);
SetClipboardData(CF_BITMAP,hBitmap);
Jonathan de Halleux, Belgium.
Jonathan de Halleux, Belgium.
|
|
|
|
|
I presume it's not working ?
At first glance, I don't see you giving up ownership of the bitmap, which now belongs to the clipboard.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
In GDI you had Detach function inheretid from CGdiObject, but in Bitmap, I don't see any similar function ???
How do you detach the HBITMAP from Bitmap object ?
Jonathan de Halleux, Belgium.
|
|
|
|
|
I have no idea, sorry. Perhaps you need to create a HBITMAP, a HDC, and then copy the Bitmap into it by attaching the HDC to a Graphics object after putting the HBITMAP into it.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|