Whoa! you have many questions.
Well here are the answers to your questions:
1.
How on earth should one know that the point will go to the Desktop?
Why? Allocatememory() help says:
"Allocates a contiguous memory area according to the specified size (in bytes). If the needed memory is available, *MemoryID will get the start address of the memory area, else it be 0.
Note: All the allocated memory areas are automatically freed when the programs ends. "
What has it got to do with Desktop????
In the DesktopOutput() procedure you only poke into this memory area. And it is returned as a buffer(????). Why a red dot is put on the desktop?
Well, as I was bored and there was nothing to do, I started to think to make something very unuseful and drawing to the desktop is something like that... Well, how did I know to use AllocateMemory()? It was so that when I tried to draw in a memory area (Yes, sounds crazy), the return was nothing, so I tried many times, but as I started to use big sizes like AllocateMemory(800), then I could see something, but it didn't draw to my whole desktop, so I thought that my screensize is what I need to use to get it working, and I have a 1024*768 screen here so 1024 passed succesfully. And it needs to be poked as long because the return is too big for a byte, string etc... and if it would not be poked, then it won't do anything, just eat memory...
On to the next question:
2.
So this DektopOutput() is used in StartDrawing()
How on earth did this come into your mind? I read the help again and found:
WindowOutput() : Graphics will be rendered directly on the Window
ScreenOutput() : Graphics will be rendered directly on the Screen (for games)
SpriteOutput() : Graphics will be rendered directly on the Sprite (for games)
ImageOutput() : Graphics will be rendered directly on the Image data (see CreateImage())
PrinterOutput() : Graphics will be rendered directly on the Printer
TextureOutput() : Graphics will be rendered directly on the Texture
The help tells nothing about other buffers to use (And how come Desktop into the picture? Why not any other memory chunk?)
As I said, I was bored and just tried to do something, and when I wanted to draw to the desktop, I found out there wasn't a DesktopOutput() procedure. Also, If I want to use another chunk, it maybe wouldn't draw to the desktop, and that is the bug.
now to the next question:
3.
How on earth can these Windows functions be called from such easily from PureBasic? Like (InvalidateRect_). Does this _ underscore means that it is not a PureBasic command? But how does Purebasic know from which library should it call the functions.
Besides win32hlp says this:
BOOL InvalidateRect(
HWND hWnd, // handle of window with changed update region
CONST RECT *lpRect, // address of rectangle coordinates
BOOL bErase // erase-background flag
);
We pass 0, 0, 0. Does it mean the desktop somehow? But the second parameter should be a pointer.
Yes, the underscore means it is not a PureBasic function, so it is a Basic function (maybe Visual Basic, not sure)
And InvalidateRect_() well, if hWnd is set to 0 and there is no window, it will update the desktop, and if the RECT is set to 0, then the area is the whole desktop. and the last parameter is a flag, and I didn't need any special flags, so I set it to 0.
I hope your answers are now fully answered and that you understand how everything works.
EDIT:
But how does Purebasic know from which library should it call the functions.
Why do you think you are using PureBasic?
Just joking, if you make for example your own Basic language, you have to declare all headers you need for the compiled projects of the users.
So look this:
http://msdn.microsoft.com/library/defau ... w_7ano.asp
Scroll down the page until "Requirements". You'll see it is needed to include Windows.h (header) and the library User32.lib, and it seems Fred has included and declared these in PB, if he wouldn't we couldn't use the functions with underscore...