Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,169 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,888 people online right now. Registration is fast and FREE... Join Now!




Warning Window

 
Reply to this topicStart new topic

Warning Window, I can't figure out how to make it.

TheDawnbringer
18 Dec, 2007 - 07:09 AM
Post #1

New D.I.C Head
*

Joined: 18 Dec, 2007
Posts: 3


My Contributions
ok, so I am using Dev C++ to make a program that will mess up a computers media files. It is not for black hat purposes, myself and my buddies do tournaments with each other to crack and trash boxes that we have laying around our houses. The program is supposed to make a pop-up window that looks like thisIPB ImageI have the pop-up window and button, I just can't seem to use the current code to move the words around the popup correctly or change the font size. Are there any other ways to code the words?

CODE


#include <windows.h>
#include <string.h>
#include <iostream>

/*
* This is the window function for the main window. Whenever a message is
* dispatched using DispatchMessage (or sent with SendMessage) this function
* gets called with the contents of the message.
*/
LRESULT CALLBACK
MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
/* The window handle for the "Click Me" button. */
static HWND hwndButton = 0;
static int cx, cy;/* Height and width of our button. */

HDC hdc;/* A device context used for drawing */
PAINTSTRUCT ps;/* Also used during window drawing */
RECT rc;/* A rectangle used during drawing */
/*
* Perform processing based on what kind of message we got.
*/
switch (nMsg)
{
case WM_CREATE:
{
/* The window is being created. Create our button
* window now. */
TEXTMETRIC tm;

/* First we use the system fixed font size to choose
* a nice button size. */
hdc = GetDC (hwnd);
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
GetTextMetrics (hdc, &tm);
cx = tm.tmAveCharWidth * 19;
cy = (tm.tmHeight + tm.tmExternalLeading) * 2;
ReleaseDC (hwnd, hdc);

/* Now create the button */
hwndButton = CreateWindow (
"button",/* Builtin button class */
"OK",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 0, cx, cy,
hwnd,/* Parent is this window. */
(HMENU) 1,/* Control ID: 1 */
((LPCREATESTRUCT) lParam)->hInstance,
NULL
);

return 0;
break;
}

case WM_DESTROY:
/* The window is being destroyed, close the application
* (the child button gets destroyed automatically). */
PostQuitMessage (0);
return 0;
break;

case WM_PAINT:
/* The window needs to be painted (redrawn). */
hdc = BeginPaint (hwnd, &ps);
GetClientRect (hwnd, &rc);

/* Draw the text. */
rc.bottom = rc.bottom / 2;
DrawText (hdc, "AIDS Has Been Detected On This Computer!", -1, &rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
rc.bottom = rc.bottom / 3;
DrawText (hdc, "Virus Alert!", -1, &rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
rc.bottom = rc.bottom / 1;
DrawText (hdc,  " Action Taken: None ", 20, &rc,
50 | 50 | 100);

EndPaint (hwnd, &ps);
return 0;
break;

case WM_SIZE:
/* The window size is changing. If the button exists
* then place it in the right bottom half of
* the window. */
if (hwndButton &&
(wParam == SIZEFULLSCREEN ||
wParam == SIZENORMAL)
   )
{
rc.left = (LOWORD(lParam) - cx) / 1.2;
rc.top = HIWORD(lParam) * 3 / 4 - cy / 3;
MoveWindow (
hwndButton,
rc.left, rc.top, cx, cy, TRUE);
}
break;

case WM_COMMAND:
/* Check the control ID, notification code and
* control handle to see if this is a button click
* message from our child button. */
if (LOWORD(wParam) == 1 &&
    HIWORD(wParam) == BN_CLICKED &&
    (HWND) lParam == hwndButton)
{
/* Our button was clicked. Close the window. */
DestroyWindow (hwnd);
}
return 0;
break;
}

/* If we don't handle a message completely we hand it to the system
* provided default window function. */
return DefWindowProc (hwnd, nMsg, wParam, lParam);
}


int STDCALL
WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
{
HWND hwndMain;/* Handle for the main window. */
MSG msg;/* A Win32 message structure. */
WNDCLASSEX wndclass;/* A window class structure. */
char*szMainWndClass = "WNDCLASSEX";
/* The name of the main window class */

/*
* First we create a window class for our main window.
*/

/* Initialize the entire structure to zero. */
memset (&wndclass, 0, sizeof(WNDCLASSEX));

/* This class is called WinTestWin */
wndclass.lpszClassName = szMainWndClass;

/* cbSize gives the size of the structure for extensibility. */
wndclass.cbSize = sizeof(WNDCLASSEX);

/* All windows of this class redraw when resized. */
wndclass.style = CS_HREDRAW | CS_VREDRAW;

/* All windows of this class use the MainWndProc window function. */
wndclass.lpfnWndProc = MainWndProc;

/* This class is used with the current program instance. */
wndclass.hInstance = hInst;

/* Use standard application icon and arrow cursor provided by the OS */
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);

/* Color the background white */
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);

/*
* Now register the window class for use.
*/
RegisterClassEx (&wndclass);

/*
* Create our main window using that window class.
*/
hwndMain = CreateWindow (
szMainWndClass,/* Class name */
"VIRUS ALERT!",/* Caption */
WS_OVERLAPPEDWINDOW,/* Style */
400,/* Initial x (use default) */
300,/* Initial y (use default) */
500,/* Initial x size (use default) */
180,/* Initial y size (use default) */
NULL,/* No parent window */
NULL,/* No menu */
hInst,/* This program instance */
NULL/* Creation parameters */
);

/*
* Display the window which we just created (using the nShow
* passed by the OS, which allows for start minimized and that
* sort of thing).
*/
ShowWindow (hwndMain, nShow);
UpdateWindow (hwndMain);

/*
* The main message loop. All messages being sent to the windows
* of the application (or at least the primary thread) are retrieved
* by the GetMessage call, then translated (mainly for keyboard
* messages) and dispatched to the appropriate window procedure.
* This is the simplest kind of messa.ge loop. More complex loops
* are required for idle processing or handling modeless dialog
* boxes. When one of the windows calls PostQuitMessage GetMessage
* will return zero and the wParam of the message will be filled
* with the argument to PostQuitMessage. The loop will end and
* the application will close.
         */
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}





BTW: I am using an example code from the DEV C++ compiler as the base for my code as I am still very new to C++
User is offlineProfile CardPM
+Quote Post

lockdown
RE: Warning Window
18 Dec, 2007 - 07:13 AM
Post #2

D.I.C Regular
Group Icon

Joined: 29 Sep, 2007
Posts: 376



Thanked: 1 times
Expert In: PC, Support

My Contributions
I dont know if anyone is going to help you out. Anything that is meant to harm even if not intended someone would not want to support. What if your app gets out? Then what?

Dont take offense to this because its not meant to be but you sound like a person trying to become a script kiddie. These are people (normally younger) that want to create havoc but have a lower understanding of what they are actually doing. Most dose this with .bat files but some go into C++, VB and other languages. I am a Computer Security major so I have gone threw studying all of this and I am also training for the Ethical Hacker certification.

Also since you are new to C++ and I am not a advanced user (so I am not talking down to you) that code is not taught in intro to C++. That code is pretty complicated so do you understand what that code is doing line by line? You should before working with it because after looking at it that program looks like its could be nasty to your machine.

Again I am not trying to be mean nor talk down to you. I am mainly pointing out that if you dont understand computer virus/virus/worms/hacking ect. dont mess with stuff like this. You need to understand exactly what you are doing so you understand that what could happen if it gets release to the web.

Be constructive with programming not destructive.

This post has been edited by lockdown: 18 Dec, 2007 - 07:22 AM
User is offlineProfile CardPM
+Quote Post

TheDawnbringer
RE: Warning Window
18 Dec, 2007 - 07:22 AM
Post #3

New D.I.C Head
*

Joined: 18 Dec, 2007
Posts: 3


My Contributions
QUOTE(lockdown @ 18 Dec, 2007 - 08:13 AM) *

I dont know if anyone is going to help you out. Anything that is meant to harm even if not intended someone would not want to support.

Also since you are new to C++ how do we know you are not a script kiddie? Another point is even know you dont mean to release this software what if it dose get out? I am a Computer Security major and to be honest it sounds a little fishy.



What my code is meant to do is replace all sound and picture files with text files, which I already have the code made. My brother is a coder and he helped me on that, I just wanna make this thing flashy, the pop-up is merely a pop-up that is run by the main program which will not be listed here. I also understand your concern, and I can assure you, I have no intention of harm or getting in any trouble through destruction of private or public computers that I do not own or are not designated for such "bricking". Plus, this can help me out and I'm sure many others in just making pop-ups or messages, which all I am able to do on my own is make a window with a name, but I can't do anything else. I am serious about learning C++ and my brother is helping along the way, but I feel that projects like this can help me gain crucial experience quickly.
User is offlineProfile CardPM
+Quote Post

lockdown
RE: Warning Window
18 Dec, 2007 - 07:28 AM
Post #4

D.I.C Regular
Group Icon

Joined: 29 Sep, 2007
Posts: 376



Thanked: 1 times
Expert In: PC, Support

My Contributions
That is all understandable.

(1). Jumping right into to the advanced parts of C++ is not suggested but if your brother is helping you I guess go ahead.
(2). I dont know why your brother or who ever is using the method they are to create the windows. Look into the windows API for error reporting. It will require some different lines of code but is more what you are looking for.

Besides that their is not much else I can suggest. Other might have more input but I dont want to correct a program like that.

This post has been edited by lockdown: 18 Dec, 2007 - 07:29 AM
User is offlineProfile CardPM
+Quote Post

TheDawnbringer
RE: Warning Window
18 Dec, 2007 - 08:04 AM
Post #5

New D.I.C Head
*

Joined: 18 Dec, 2007
Posts: 3


My Contributions
Thank you, also, that code was from an example that came with the DEV C++ Compiler. Is that why I am unable to get the sentence: Action Taken: None to go down? It will not go down to sit beside the button, it wants to stay up top. Do you know how to correct that? That as well as trying to change size of the type is my problem. I cannot get the words to sit in the correct places.



This post has been edited by TheDawnbringer: 18 Dec, 2007 - 08:07 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 12:24AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month