Fromethius 0 Newbie Poster

=(

Fromethius 0 Newbie Poster

Anyone?

Fromethius 0 Newbie Poster

Hello everyone

I'm trying to write a program in native c++ code that will do this:

When drawing in MS Paint and I press the P key on the keyboard, the Pencil tool will become the current tool.

I really want to stay away from installing drivers, injecting dlls, reverse engineering, and many other complex things to do such an easy task.

Normally, this would be easy but the Pencil tool in MS Paint is not a window. All those tools are inside a toolbox, and the toolbox is a window.

I could get the coords of the toolbox and then simulate a mouse event on the coords + the offset of the pencil tool but you can get rid of the toolbox and then it has no coords and thus, the program fails.

Really, I'm looking for a way to run the code that is run when you click the pencil tool in MS Paint. I want the Pencil tool to become the current tool when I press P on my keyboard.

Also, I plan on distributing this application so I can't apply changes on my computer to get this to work.

Here is my code so far. The comment is where I need to insert the code that changes the current tool to the pencil tool:

http://rafb.net/p/Nfb2lT78.html

Thanks for any help.

Fromethius 0 Newbie Poster

Hi everyone.

For the past day I've been trying to find a good way to handle keyboard input.

Naturally, I wanted to just use WM_KEYDOWN and WM_KEYUP to handle my events, but they proven to have limitations. In my game there was a keyboard delay. If you pressed and held down the right arrow key, the character would move one pixel to the right, stop, then continue moving. I wanted the character to immediately start moving and continue moving once the right arrow key was pressed and held.

Another problem with using just WM_KEYDOWN is that if you are moving your character with the right arrow key and then press spacebar, your character stops moving. Apparently this WM_KEYDOWN message couldn't handle more than one key being processed at a time.

I look into DirectInput and get it working finally. I notice there is none of that keyboard repeat rate delay and it could handle more than one key being held at a time. The problem was, it was messy. Basically, DirectInput was overkill. Also, handling KeyUp messages with DirectInput was hell.

Now I look into GetAsyncKeyState. It looks good, but it seems a bit messy and slow.


Overall, I'm looking for a way to use WM_KEYDOWN and WM_KEYUP to handle more than one key at a time (so if you're moving and press space you don't stop moving for example) and I also want it to not have a delay. For example, …

Fromethius 0 Newbie Poster

Without creating global variables, is there a way to pass variables to the WindowProcedure that handles the messages?

For example, if I create a variable and initialize it in WinMain, is there any way to use it in my WindowProcedure?

What I am doing is this. I have a class called Map. I also have a class called Texture and Window.

When I create Texture and Window, certain variables are created such as texWidth, texHeight, windowWidth, and WindowHeight inside of the class.

In my Window Procedure, I need to use those variables held inside of Texture and Window for some function calls.

Is there any way to do this easily? I would really like to keep it simple and try to avoid global variables if possible.

Fromethius 0 Newbie Poster

I've been working on this for a couple days now. I'm really looking for the best way to render. Nothing too complicated but something that is fast, reliable, and powerful. I've seen many websites and about each one shows a different way. I've probably gone through about 5 different ways so far. But I'm really looking for a good, reliable one and I don't think I have found it yet.

I'm looking for a way that if the game is minimized, then no rendering will take place. Such that, the CPU usage is less than 5%. Also, a lot of people say handle the message to check when the game is minimized and then sleep every 50 ms until the game is back up. That just seems so messy to me. I'm looking for a way that will not Render or anything like that when the program is minimized, but when it is maximized, the device will reset.

I'm looking for a way that will process messages very fast (i suppose with peekmessage combined with a while loop) and a way that will allow the program to exit once the message is WM_QUIT. Perhaps the outer loop being a while loop checking peekmessage for WM_QUIT? I'm just not sure. I guess I'm just looking for a perfect loop. I know there probably isn't one, but there has to be at least some good ones.

Most of the examples I find on the web, the CPU usage is …

Fromethius 0 Newbie Poster

Bump

It might help if I give you my code so here: My entire source:

http://rafb.net/p/OAkQDj57.html

Fromethius 0 Newbie Poster

Hello everyone,

Is there an equivalent to SendKeys.Send in C++? I have looked into keybd_event and SendInput, but to my knowledge you can only send one key at a time with those functions.

Thanks for any help.

Edit: I'm not using the .Net Framework so I can't use any of that stuff.

Fromethius 0 Newbie Poster

It works fine with games written by professional game companies so it isn't my computer and I don't handle any code when my game is minmized/maximized

Fromethius 0 Newbie Poster

If I launch my DirectX program, full-screen initializes. If I alt tab out of it, it alt-tabs as normal. However, if I then maximize it so it has the focus of my computer again and then alt-tab for the second time, the window doesn't minimize. The taskbar shows up but the program doesn't minimize. It's like, the first time I alt tab it works perfectly normal but then second time I do it, it doesn't work. Anyone know why? I would really like to fix this. Thankssss..

Fromethius 0 Newbie Poster

Hello everyone,

I have this code:

Image* newImage = Image::FromFile(szFileName);
   Bitmap image(50, 50);
   Graphics graphics(&image);
   HDC gfxHDC = graphics.GetHDC();
   graphics.DrawImage(newImage, 0, 0);
   int pixel, row;
   for (pixel = 1, row = 1; row <= 50; pixel++)
   if (GetPixel(gfxHDC, pixel, row) != RGB(255, 255, 255))

Anyways, whenever I use GetPixel, the IF statement ALWAYS runs. Even if it is a completely white image. I suspect that either DrawImage isn't drawing it onto gfxHDC or that GetPixel isn't reading the pixels from gfxHDC or I don't even know. The point is, it isn't working and I need some help.

Thanks.

Fromethius 0 Newbie Poster

--------------------------------------------------------------------------------

When using this with the DrawText API, I make the rectangle that the text is contained in the width of the return value of GetTextExtentPoint32


I know I am using the right parameters, but sometimes the rectangle is way too big (over 15 pixels wider than the actual width of the text) and sometimes the rectangle is too small.

It seems that this API is a little.. screwed up perhaps? If I input "WWWWWWWWWWWW" for example, the rectangle containing the text is around 20 pixels too big but if I input "iiiiiiiiiiii", the rectangle is around 20 pixels too small.

I tried using SetTextCharacterExtra, but that just screwed things up even more. I'm looking for a more accurate and precise way to set the rectangle's width via the width of the text. Btw, there will never be any spaces, numbers, or symbols as the text. The width of the text will only ever contain the 26 lowercase letters and 26 uppercase letters.

Thanks for any help. :)

Fromethius 0 Newbie Poster

Hello everyone and thank you for taking the time to read my post

I am running Visual C++ 2005 and I'm having some trouble with GDI+.


I have two bitmaps:

Bitmap* pngFrame;
Bitmap* pngEmblem;

I initialized them in a function I use, and I can display them no problem like this:

PAINTSTRUCT ps; 
BeginPaint(hwnd, &ps);
Gdiplus::Graphics* gfx = new Gdiplus::Graphics(ps.hdc); 
gfx->DrawImage(pngFrame, 80, 12); 
gfx->DrawImage(pngEmblem, 80 + ((17 - (INT)pngEmblem->GetWidth()) / 2), 12 + ((17 - (INT)pngEmblem->GetHeight()) / 2)); 
delete gfx;  
EndPaint(hwnd, &ps);

Now, that works all fine and dandy. However, in another event, when the user clicks a button. I would like to draw the pngFrame, draw the pngEmblem on top of it, and then save it as one picture.

For example (pseudocode):

gfx->DrawImage(pngFrame);
gfx->DrawImage(pngEmblem);
gfx->SaveTo(C:\\picture.png);

They are PNG files so it handles the transparency automatically. But yea, can I get some help with this one?

Fromethius 0 Newbie Poster

All week now I have been searching for a good way to load and display PNG files. Every solution I try never works.

So now I am posting on the forums. I am not looking for a huge library. In fact, I'm not looking for a library at all. All I want to do is do easily be able to load and display PNG files.

I'm using Visual C++ 2005 Win32 API.

Fromethius 0 Newbie Poster

I have Windows XP with Dev-C++. I created a Windows Application and added #include <gdiplus.h> to the top of the file. I made sure I had gdiplus.h and all the files it required in my include folder. However, when I try to run the application. I get these errors: http://rafb.net/p/wD4DPa78.html The last two errors repeat over and over again around 250 times. I checked the GdiplusEnums.h file and see this: http://rafb.net/p/ncqJg732.html As I said before, this line: enum EmfPlusRecordType; is giving me the error that says: 534 C:\Dev-Cpp\include\GdiplusEnums.h use of enum `EmfPlusRecordType' without previous declaration. Can I get some help with this one? I really need to use GDI+ with my Dev-C++ Win32 application in order to display PNG files because it is the easiest way I know of to display PNG files without using lots of user-created external libraries.