Greetings to everyone. On my Windows 10 PC, I use Avast AV for an extra layer of protection on Windows Defender. But with the installation of Avast AV, the Avast Secure browser was installed. I don't really use it, so if I uninstall Avast Secure Browser, will it cause any problems with Avast AV on my PC? Please, give me some suggestions about this. Any kind of reply would be greatly appreciated.
In playing around with some basic GDI stuff, I had the need to draw an object in the middle of the main window and then when a button is clicked, draw that object progressively closer to some corner (in my code below, the object moves to the lower right corner, but ultimately I'd like it to move to any corner). So my question is: how to calculate those new X/Y coordinates with each button click?
The initial X/Y coordinates are calculated in response to WM_SIZE like:
nScreenWidth = LOWORD(lParam);
nScreenHeight = HIWORD(lParam);
// the window is not being resized right now, so these two variables aren't being recalculated.
nX = (nScreenWidth - nObjectWidth) / 2;
nY = (nScreenHeight - nObjectHeight) / 2;
When the button is clicked, new X/Y coordinates are "calculated" like:
if (LOWORD(wParam) == ID_BUTTON)
nX += 20;
nY += 10;
InvalidateRect(hWnd, NULL, TRUE);
The object is drawn in response to WM_PAINT like:
HDC hdc = BeginPaint(hWnd, &ps);
// draw object at nX, nY
You can count on one hand how many GDI projects I've done in the past (and have fingers left over) so I'm walking in somewhat uncharted territory for me. As a visual aide, if you envision a straight line drawn from the middle of the screen to one of its corners, each pixel of that line is on an X/Y coordinate. What would that calculation look like?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
I don't think it is a straightforward calculation as you would need to move more pixels in the horizontal direction than the vertical (assuming landscape view). If you use GDI+ it is slightly easier as you can use float values for the points and Windows does the smoothing. But I am not 100% clear as to the actual problem. And incidentally, as far as handling messages and repainting, your code all looks correct.
Here is a very simple method of moving the box:
You need to start by calculating the value of the slope ratio between horizontal and vertical size of the Window's client area. You need this as a floating point value as it will be used to calculate positions further on.
Declare a static float value named slopeRatio, and add the following code to either the initialisation (e.g. WM_CREATE), or whenever the Window is resized (WM_SIZE).
// get the slope of the client area diagonal
float horiz = (float)rcClient.right; // Horizontal width in pixels
float vert = (float)rcClient.bottom; // Vertical height in pixels
slopeRatio = horiz / vert;
Then when you need to calculate the new X and Y positions of your drawing (after the button press) do the following:
// currentX and currentY are declared elsewhere
currentX += 30; // or whatever value you wish to move it
tempY = (float)currentX / slopeRatio;
currentY = (int)tempY;
InvalidateRect(hWnd, nullptr, TRUE);
so, i was doing some programming with eclipse and stuff. But then i noticed that all of my .JAR files suddenly looked like a pinguin with some painting stuff on his hands. i need help, cause im not sure what is going on!! I use windows.
[SOLVED] I had to right click a JAR file, and "press open in application" then select Java JDK. For some reason i had two of those...
I mean to check retrieved from DHCP server IP address is exist a some device in local network with same IP address or not. If exist I have to send DHCPDECLINE to DHCP server and request another IP address
What are you writing? This is all handled by the network stack, so a normal application wouldn't even know this was going on.
If the IP is already bound to the adapter, you have no way of knowing that because if you try to ping it using the easy and normal methods, you'll only get a response from your own machine, like "ping localhost".
If you try to do this before the IP is bound to the adapter, you don't have an IP yet, so you can't use the easy and normal methods here either because they rely on the IP already being set. So the only way to do this would be digging deeper into the network stack and crafting your own packets, and that take admin permissions to be able to do that. A normal user wouldn't be able to do that.
In the real world, DHCP servers can be setup to do this themselves, and it's also managed by reserving ranges of IP addresses for static allocation, "ad-hoc allocation", and other ranges for dynamic allocation. Today, you would be hard pressed to get an IP that was in use already from the server.
I'm writing a dhcp-client code for my embedded application on cortex. Just I'm writing and debugging code on Windows. I'm testing how dhcp-requests are creating and how responces are handling. After that I'm porting this code to my embedded application
I have worked with and implemented a system service with the DHCP protocol. After you have received the DHCPACK you need to broadcast an ARP and make sure that no other node on the network has a claim to the address. You can use either the SendArp[^] or ResolveIpNetEntry2 function[^] to accomplish this.
I have a very complete understanding of the DHCP standards so if you have any questions feel free to contact me.
Remember that DHCP is an honor system[^] and that there are no built-in security measures.
I researched and implemented a signed/encrypted DHCP protocol but it's completely non-standard and just something I was experimenting with. All of these old standards are garbage... and need to be replaced.
Oh... here's a pro tip: After you get your address offer and assign the address make sure to close the listening socket. Guess what happens if you leave a listening socket open for 12+ hours without reading the buffer? The socket buffers fill with 12 hours of whatever arrived at the listening port! I made this mistake in my first iteration.
In final I'll plan to used this code in the embedded application with hardware ethernet chip. It supports only a little count of sockets and I have to use a single socket for some sequence of tasks (DHCP, PING, SNTP etc).
I'm having trouble with my system and checked system files, only to find that the file wininet.dll in some unpronouncable folder is corrupted and couldn't be repaired.
So I went to find that folder location, starting with Windows/Winsxs, only to find thousands of subfolders! Many of them appear to contain system dlls, and apparently lots of different versions of the same dlls.
I could understand the need for keeping different versions of some system files - but 20K folders of files???
Is it normal to have so many? Or may that be another symptom, or even the cause of the problems I'm having? Could this be the work of a virus or other kind of malware? Or is that the result of Windows working 'normally' for a couple of years?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
Last Visit: 31-Dec-99 18:00 Last Update: 28-Sep-22 22:50