|
i never read all of your long post, so my reply may be incorrect.
your string
"/\*.*?\*/"
should you use double back-slash rather than single one?
"/\\*.*?\\*/"
includeh10
|
|
|
|
|
includeh10 wrote:
should you use double back-slash rather than single one?
No. The single back-slash is correct; it is how the user would enter it. A double back-slash is only required if you are hard coding the expression in a C/C++ string, in which case the double back-slash translates to a single back-slash (in the string).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi, All.
I'm working on a Win32 project that draws some stuff on a canvas, and I need to add an option that saves whatever drawn on a canvas into a file. I have succeded in creating an empty .png image, however, I'm not seem to be able to save whatever drawings I make on the screen (I'm tryning to use DrawImage method).
for example
-----
for(int i=1; i<=size; i++)
{
dx = elements->x;
dy = elements->y;
if((translateToScreen(dx, true) > (-mcoord.eDx + 3 + offsforax + yaxoffst))&&(translateToScreen(dy, false)>(umin.y*cRatio.y*zoomr.y + offsety * cRatio.y*zoomr.y)))
{
graphics.FillRectangle(&blk, (REAL)translateToScreen(dx, true)+2, (REAL)translateToScreen(dy, false)-5, (REAL)6,(REAL)10);
graphics.FillRectangle(&col, (REAL)translateToScreen(dx, true)+3, (REAL)translateToScreen(dy, false)-4, (REAL)4,(REAL)8);
}
elements++;
}
bm = new Bitmap(current.right - current.left, current.bottom - current.top, &graphics);
gr.DrawImage(bm, current.left, current.top, current.right-current.left, current.bottom-current.top);
}
-------
In this piece of code, I'm trying to draw some points on a screen, as well as in a bitmap object, but this aproach fails. What should I change? Thanks.
Alex.
|
|
|
|
|
I have never used GDI+ till today when I decided to look into your question so I'm not a GDI+ expert, this is just what worked for me.
First DrawImage() takes an image (in your case bm) and draws it to what it's been initilized to draw on. I'm guessing you did a Graphics gr(dc.m_hDC) so it's going to try to draw a blank image to your window's DC. What you want, is to take what's on graphics (the DC) and put it into the Bitmap. This is tricky because graphics acts as an interface on which to manipulate something. You could get it directly from the DC like this however, once you've finished your drawing.
Bitmap* bitmap = new Bitmap(50, 50, &graphics);<br />
Graphics* bitmap_graphics = graphics.FromImage(bitmap);<br />
<br />
HDC source_dc = graphics.GetHDC();<br />
HDC destination_dc = bitmap_graphics->GetHDC();<br />
<br />
BitBlt(destination_dc, 0, 0, 50, 50, source_dc, 0, 0, SRCCOPY);<br />
<br />
graphics.ReleaseHDC(destination_dc);<br />
bitmap_graphics->ReleaseHDC(destination_dc);
Hope this helps.
|
|
|
|
|
That's very helpful and I will definitely try it, because the only thing I've come up with is to duplicate all the methods that do any kind of manipulations on the screen, and since I used to transform it, things got extremely time-consuming.
Thanks,
Alex
|
|
|
|
|
Here's the deal. I want to write a program that, part of it will display either in web or tree form the interconnectivity of files. For example, one code file calls this other file which calls two other files. This web or tree would show, for example, the parent child relationship of these files. I just want to know if there's any open source code that will display this for me. I'd hate to duplicate code, you know.
Danny
|
|
|
|
|
I am fairly new to VC++ and programming in windows, and am writing a program that consists of one dialog box as the entire UI. After finishing the program, I close the dialog box, and there is an empty window that I have to close also. Is there a way to make the dialog box open in the window? Or possibly to not make that window appear?
|
|
|
|
|
Do you use Visual Studio (6.0)? You can create an MFC application in Visual Studio and, following the wizard, make the application dialog based. That would make the whole program one big dialog box. In this case I haven't seen the problem of having an extra window.
Danny
|
|
|
|
|
hmmm, yes I am using Visual Studio(dot NET), I was not the original creator of the program, but am working on it now. I will try to make a dialog based app and transfer the code over to see if there is a difference. There isn't a way to check how the program was originally made is there?
|
|
|
|
|
Will it be possible from with in the driver to know the details of applications acessing the driver.? (e.g Name, Path etc)
Any pointers..thanks
Thanks,
|
|
|
|
|
If your driver is processing the IRP in the context of the process thread you can use "IoGetCurrentProcess"/"PsGetCurrentProcess" or "PsGetCurrentProcessId" or even "IoGetCurrentThread/PsGetCurrentTHread" or "PsGetCurrentThreadId".
These could help you determine at least the PID of the process. Io/PsGetCurrentProcess actually returns an "undocumented" data structure that represents the current process information. If you do a search on the net or do "dt _EPROCESS" in the kernel debugger you may be able to find out what information you need from it, but of course it may vary from OS to OS or even from Service Pack to Service Pack.
The other method you could use if you are in the current thread process is attempt to find the user mode TEB and PEB if there is one. You can then just traverse this memory and find out all the information as well. Of course this is bad since the memory can go away so you'd need to ensure you protect your driver from this.
Another method would be for you to create a user mode componet that could talk with your driver and communicate some information down to it, such as a mapping of PID's to Processes or vice versa (Your driver could call your service with the PID and it could do the mapping).
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
Thanks toby,
I am able to get PID at this point,I was wondering you are aware of any way to get File name or the path using this PID.
I read about some references to PsGetProcessImageFileName(), But haven't been able gather enough information to be able use it.
Any suggestions...
|
|
|
|
|
How do you cut out the code that compiles the hpj file every time? I can't find it in the (VC) help files or the compiler options. Thanks for any help on help.
|
|
|
|
|
Look at the Project --> Dependencies menu item.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
Exclude the HPJ from the build.
|
|
|
|
|
I have a problem with linking..
everything worked good until I noticed that there were to many lines of code to be working with so I decided to split it up to a few .cpp-files, and all of them starts with a "#include main.h" , and when I tried to compile it and I got some problems with 2 objects that is defined multipled times... how can I include main.h from multiple files without getting the defined multiplied times problem?
btw I'm using MSVC++ 6, and Allegro
regards /Joakim .A
Joakim .A - State: VB6 -> VB.NET
|
|
|
|
|
Have you looked into the #pragma once directive?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
No, I haven't... thing is that I have a simular application that is split up to different files and that works, I've scanned trough it 100 times and compared it with my application and can't find anything that is different with the layout.
Joakim .A - State: VB6 -> VB.NET
|
|
|
|
|
That depends on what is in main.h. Are there just prototypes and classes/structs defined or does it also contain function difinition (which should be specified as inline). If you are not defining the same function twice in your code, it is possible that the compiler is generating a function in every file that includes main.h. The simpilest solution is to back up to where all the code is in one file (and compiles OK), then transfer the functions from the origanal file to the new file one at a time and recompile each time to see if an error occurs.
Note: inline is a suggestion to the compiler; if an inline function is large, then the compiler will generate a function instead of inlining it. This some times results in the problem you are having, but it is rare and the compiler may have safeties in place to prevent this.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
well.. I have prototypes for both classes/structs and function in main.h, I'm not sure how I specy function defenitions as inline.
the linking-problem I have is with some variables not with any function so far. but maby if my function isnt defined as inline the compiler get some problem with variables too.
I've made rar's of the source. one with the one-file and one with the multi-filer version, if that would make it easier to look at.
Single-file version
Multi-file version
edit:
btw the two variables I'm having a problem with is stair and gameover
Joakim .A - State: VB6 -> VB.NET
|
|
|
|
|
I see by your reply to sunit5 that you probably found the problem (declared but undefine variables).
As for specifing inline:
inline int func(int n) {...}
If the inline function is needed by several files, then you would place it in a header file.
If the inline function is only needed by one file, then place it in that file.
Given a choise between macros and small inline functions, prefer inline functions (when ever possible). This does not only make reading the code easier, it also lets the compilire validate the arguments (which prevents hard to find bugs).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
i had similar problem.but i did a mistake.i defined an external variable in main.h.which was included in every .cpp file.one should only declare external variable ,functions, classes or structures.pls check out any defination is not present in main.h
|
|
|
|
|
I'm not sure what you mean here. but I do have defined variables as external in main.h, but I don't define them again in the other .cpp-files again (as I guess you had done)
aah now when I come to think of it (damn I'm a lousy c++ user ) I need to check if I defined those variable instead of declaring them
Joakim .A - State: VB6 -> VB.NET
|
|
|
|
|
Is there a way to search for a particular word in a file, no matter where it may be placed. I don't think opening the file and just using getline will work. Maybe there is a tool out there I can make use of in my code?
Danny
|
|
|
|