Ok, here's what I'm trying, it's just giving me a blank (black) 500x500 bitmap: CDC memDC; memDC.CreateCompatibleDC(GetDC()); CBitmap *bmp = new CBitmap(); bmp->CreateCompatibleBitmap(&memDC, 500, 500); CBitmap *old = memDC.SelectObject(bmp); CRect rc(0, 0, 500, 500); memDC.FillRect(rc, new CBrush(RGB(0, 255, 255))); memDC.TextOut(50, 50, "BLAH"); //This stuff writes the bitmap and I know that it works. HANDLE hDib = DDBToDIB(*bmp, BI_RGB, NULL); WriteDIB("c:\\test\\testbmp.bmp", hDib); memDC.SelectObject(old); I have also tried to put the "memDC.SelectObject(old);" line before the bitmap writes and it gives the same problem. I know that the bitmap writing code works, I've used it before on CBitmaps just fine, so I'm sure that the problem exists in this drawing code somewhere. This code is being run from a CDialog, so that's where the GetDC() comes from. -- Rocky Dean Pulley -- DreamSys Software -- http://www.dreamsyssoft.com
rocky_pulley
Posts
-
Capturing HDC -
Capturing HDCI have an issue where I have a function that takes an HDC and draws to it. Instead of just displaying the data in a window, I want to write it to a bitmap file. I don't want to show the window at all, so I'm hoping that I can do this with a hidden window some how. I've tried calling GetCurrentBitmap() on the CDC object and that did not give me a valid bitmap. I also tried the following: hDC = GetDC(hDCWnd); hBmp = CreateCompatibleBitmap(hDC, 500, 500); SelectObject(hDC, hBmp); MyFuncToDraw(hDC); CBitmap* bitmap = CBitmap::FromHandle(hBmp); but that only gave me a blank bitmap. Does anyone have any idea how I can get a valid CBitmap so I can save it to a file? Is this even possible?? -- Rocky Dean Pulley -- DreamSys Software -- http://www.dreamsyssoft.com
-
Bitmap from HDCI have a function that will draw to an HDC, I need to create a bitmap from that, what would be the best method? Can I create a bitmap and get it's HDC or something like that? Thanks! -- Rocky Dean Pulley -- DreamSys Software -- http://www.dreamsyssoft.com
-
Bitmap Resource LoadingCan you view the splash.bmp from the resource editor? -- Rocky Dean Pulley -- DreamSys Software -- http://www.dreamsyssoft.com
-
need help about p2p file transferHere is some code to get you started. printf("transferring files...\n"); /* Transfer files here */ printf("done!\n"); -- Rocky Dean Pulley -- DreamSys Software -- http://www.dreamsyssoft.com
-
Firewall???it's doubtful there will be a DLL to do everything you need. If you want a real firewall you will need to do some driver level programming. I would suggest you start smaller. -- Rocky Dean Pulley
-
Data Overflow errorIt sounds like the number you are passing in is just too big. If the numeric field only supports a max value of say 65535 and you pass it in a long value that's say 1234567, then it will throw an overflow exception. I guess a way to fix it would be either to change the size of the numeric field in the database, or if that's not possible you can return an error to the user or just set it to the max size and ignore the rest of the number. -- Rocky Dean Pulley
-
correct way in c# to...Hi, I have a user thread and I need to tell it to run some code in the GUI thread. I was thinking that maybe I would use SendMessage and create a message handler for this but it sounds like more of a C/C++ way of doing it. Is there something in C# line this? Kind of like java has SwingUtilities.invokeLater() -- Rocky Dean Pulley
-
Point on a linethanks a lot -- Rocky Dean Pulley
-
Point on a lineI'm trying to find out if my mouse position is on a specific line. I've tried using the slopes of the line and of the mouse position from the starting point but this doesn't work because when you get close to the starting point and the line is almost horizontal the slopes vary greatly. Has anyone done this sort of thing before? Thanks -- Rocky Dean Pulley
-
open up a file as read-onlyI see, you are trying to open with word and not with your own program for reading. What you want to do will probably need to use word OLE automation. I would suggest doing some searching for just that, it's not as simple as just executing the program to do this. It's actually not much more code but understanding the concepts is a bit more complex. I haven't done this sort of thing in a long time so I don't know the code off hand, but I'm sure a quick google search will find something. -- Rocky Dean Pulley
-
open up a file as read-onlyAssuming that you meant CreateFile, pass the second parameter as GENERIC_READ. -- Rocky Dean Pulley
-
Comma Seperated StringArrayList l = new ArrayList(myString.Split(',')); -- Rocky Dean Pulley
-
adding information to a file without overwriting old infotry to open the file with FileMode: FileMode.Append -- Rocky Dean Pulley
-
Scroll Bar hogging focusthanks, that worked. -- Rocky Dean Pulley
-
Scroll Bar hogging focusThanks, but it looks like neither the UserControl class nor the VScrollBar class has these events available. -- Rocky Dean Pulley
-
Scroll Bar hogging focusHi, I'm creating a control, I do painting on the form and it has 1 scroll bar control, no other controls on it. I have a keyDown/keyUp handler and they work just fine until I hit the arrow keys, then the scroll bar grabs the key focus and I can't get it back. How can I stop the scrollbar from getting the key focus, I don't want it to be able to grab the key focus at all. Thanks! -- Rocky Dean Pulley
-
Which is faster...Define faster. Do you mean faster to execute or faster to develop? Faster to execute is most likely direct Windows API but with optimization in the compiler you won't really notice a difference. If you mean in speed of developing, well, I would say MFC, but it really depends on how well you know MFC and how well you know the windows API. -- Rocky Dean Pulley
-
Any Function in VC++ that can retrive the Unique ID of my computer,What Unique ID? -- Rocky Dean Pulley
-
Getting command line parameters of a running processThanks, that's what I'm about to try. I was hoping there was a way to do it without injecting anything but this will do I think. Thanks, -- Rocky -- Rocky Dean Pulley