|
Are you using the code link above the edit box? Alternatively you can just type the HTML direct into the edit field.
Use the best guess
|
|
|
|
|
Hey, come on, this should be simple! Its a casting issue!
I think some times people learn C++ without paying any attention to the fact that it is C as well.
|
|
|
|
|
<pre lang="Thanks, next time I'll ask something more complex if stuff like this is inappropriate"></pre>
Richard - this is what happens when I post as "plain text". Aslo there is no preview.
So here is the message as code - again "Thanks, next time I'll ask something more complex if stuff like this is inappropriate"
|
|
|
|
|
You need to clear the checkbox at the bottom that says "Treat my content as plain text, not as HTML". There are lots of useful features to the edit pages on these forums, created by the CodeProject staff's hard work and dedication to making this site easy to use. It would be a good idea to spend some time getting familiar with them all.
Use the best guess
|
|
|
|
|
I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.
I have created rectangle region for each line and trying to move the line.
When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.
How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC. Please help me how can I do it. Any help is highly appreciated. Thanks Sujan
|
|
|
|
|
You should draw all the lines in the code that handles the WM_PAINT message. Each time a new line is created, you save the details in a list or similar array. Then as your paint code is called, it should iterate that list and draw each line.
Use the best guess
|
|
|
|
|
how can I implement a transform for each line. I want to pick a line by mouse and then move it anywhere on the screen and place it. drag and move.
Currently I am defining a a rect for each line and doing InvalidateRect() and moving and when this line is crossing other line , the other line is getting removed or wiped out. How can I move lines on screen without affecting other lines.
Thanks Sujan
|
|
|
|
|
I just explained what you have to do; redraw them all, not just the one that has moved. You need to invalidate the entire Window, or ensure that you check each line within the invalidated rectangle. Understanding this basic concept is key to writing Windows applications.
Use the best guess
|
|
|
|
|
Understanding this basic concept is key to writing Windows applications
very true. You had already justified it in your first reply.
|
|
|
|
|
Richarsd just told you! Learn to read before learning to code.
|
|
|
|
|
That is perhaps the most ugliest way to solve the problem and has many horrible disadvantages ... IT IS OLD SCHOOL HORRIBLE DONT DO IT.
Problems you will definitely encounter:
1.) The draw process become slower and slower the more lines you have to draw
2.) As your draw process is contained inside the WM_PAINT message your can't thread it
3.) Your application becomes locked and unresponsive while in the draw process
4.) Every time you resize the window it will redraw all the line database
5.) Every time you move the window order or position it will do an entire redraw
Get an old copy of MS_WORD and open a 1MB image file if you want to see what it looks like.
Old versions of many Cad programs and Corel draw were practically unusable because they used the above technique and we have long since moved on from it.
The correct and more modern way to do this is to create a drawing thread that converts your line database onto a memory DC. That is all the thread does all the time when triggered.
The WM_PAINT message simply puts the last finished memory DC from the thread to screen.
Usually every database alteration is held so you can also undo-redo function it.
The obvious advantages is your program never suffers non responsive or semi locked behavior no matter how complex the drawing gets and the application drawing process does not flash and carry on.
Let me know if you get stuck and I will do a quick stub to show you how it works.
modified 11-Aug-13 11:09am.
|
|
|
|
|
When say the define of function memcpy, I say it.
_CRT_INSECURE_DEPRECATE_MEMORY(memcpy_s) void * __cdecl memcpy(_Out_opt_bytecapcount_(_Size) void * _Dst, _In_opt_bytecount_(_Size) const void * _Src, _In_ size_t _Size);
I say the file sal.h, it says that the macro will tell the compile what the usage about this function. but I do not know the compile will do any operation about this macro. If prompt any error when compiling?
|
|
|
|
|
That macro tells you that you shouldn't use that function because it is prone to errors and exploits.
Use memcpy_s instead.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I can get the linked functions in any file by using IMAGE_IMPORT_DESCRIPTOR, but how in this world I can get their addresses?
Assuming AddAtomA is the target
....
Asm code:
(jmp dword ptr ds:004050b8)in memory address of 004050b8 is 779B9EB8 which is function AddAtomA
so is there any way to show the AddAtomA address while using IMAGE_IMPORT_DESCRIPTOR
or showing the place where it will be called in the program?
|
|
|
|
|
The actual address of a function that is imported from another module is resolved while loading your image. If the other image is a dll then it can be loaded to any address if it has a relocation table. If you are curious about the address of a function whose code is in a builtin system dll then you can ask the function address with (GetModuleHandle() or LoadLibrary()) + GetProcAddress() yourself in your program without reading anything from an exe/dll file as some builtin dlls (kernel32, user32) are loaded to the same virtual address in the virtual memory space of every process in the system (at least on 32 bit windows versions, never tried the 64 bit ones). This is an old trick. This has nothing to do with the IMAGE_IMPORT_DESCRITPTOR of a specific image, this way you retrieve a constant that is guaranteed to be constant from system startup to system shutdown.
|
|
|
|
|
thanks
|
|
|
|
|
You are welcome! Was everything clear?
|
|
|
|
|
BTW, this trick is guaranteed to work only with user32 and kernel32, I never tried it with other dlls. These dlls are usually mapped to 7xxxxxxx addresses as you see in your example.
|
|
|
|
|
pasztorpisti wrote: some builtin dlls (kernel32, user32) are loaded to the same virtual address in the virtual memory space of every process in the system
Don't forget about ASLR![^]
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
You are right, thank you for mentioning. I was playing around with these things long ago...
|
|
|
|
|
The dbt.h is included with #define WINVER 0x510.
This is the only thing - commentary (?) I have been able to find in dbt.h ( Windows7.1 SDK) version.
This header does not defines the RegisterDeviceNotification!
So where is RegisterDeviceNotification actually defined? In which SDK ??
What am I missing ??
typedef struct _DEV_BROADCAST_HANDLE {
DWORD dbch_size;
DWORD dbch_devicetype;
DWORD dbch_reserved;
HANDLE dbch_handle; // file handle used in call to RegisterDeviceNotification
HDEVNOTIFY dbch_hdevnotify; // returned from RegisterDeviceNotification
//
// The following 3 fields are only valid if wParam is DBT_CUSTOMEVENT.
//
GUID dbch_eventguid;
LONG dbch_nameoffset; // offset (bytes) of variable-length string buffer (-1 if none)
BYTE dbch_data[1]; // variable-sized buffer, potentially containing binary and/or text data
} DEV_BROADCAST_HANDLE, *PDEV_BROADCAST_HANDLE;
Any constructive help would be greatly appreciated.
Cheers Vaclav
|
|
|
|
|
MSDN says it's defined in <Winuser.h> .
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
MSDN also says to include <windows.h>
|
|
|
|
|
Simply include <windows.h> as MSDN says.
It works for me.
|
|
|
|
|
The documentation[^] explains which headers to include and versions support this function.
Use the best guess
|
|
|
|