×
Ir ao conteúdo
  • Cadastre-se

Arthur160

Membro Júnior
  • Posts

    14
  • Cadastrado em

  • Última visita

Reputação

11

Informações gerais

  • Cidade e Estado
    Palmital/SP
  • Sexo
    Masculino
  1. Agora eu entendi. A Função não deve ser int e sim, HBITMAP. E também as funções WindowX() e WindowY() devem ser declaradas manualmente e eu antes achava que elas eram declaradas na própia API do Windows mesmo. Mas tinha dado um erro ao coloca-lás e depois achei que você tinha feito algo para usar essas funções, mas, agora entendi, você que declarou elas manualmente.
  2. Olá galera do Clube do Hardware! Eu estou fazendo um sistema operacional e eu quero no meu sistema operacional que ele após ele executar as rotinas ele faça aparecer um cursor do mouse que o usuário possa mover usando o mouse. Como vou fazer isso? Atenção: Eu estou usando o compilador NASM para compilar o sistema.
  3. Deu mais um erro: InvertColors.cpp:8:5: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch] int y1 = GetSystemMetrics(SM_YVIRTUALSCREEN); ^~ InvertColors.cpp: In function 'int CapturaTelaInvertida()': InvertColors.cpp:20:12: error: invalid conversion from 'HBITMAP' {aka 'HBITMAP__*'} to 'int' [-fpermissive] return btm; ^~~ InvertColors.cpp: In function 'LRESULT WndProc(HWND, UINT, WPARAM, LPARAM)': InvertColors.cpp:40:46: error: invalid conversion from 'int' to 'HGDIOBJ' {aka 'void*'} [-fpermissive] DeleteObject(CapturaTelaInvertida()); ~~~~~~~~~~~~~~~~~~~~^~ In file included from C:/MinGW/x86_64-w64-mingw32/include/windows.h:71, from InvertColors.cpp:1: C:/MinGW/x86_64-w64-mingw32/include/wingdi.h:2722:49: note: initializing argument 1 of 'WINBOOL DeleteObject(HGDIOBJ)' WINGDIAPI WINBOOL WINAPI DeleteObject(HGDIOBJ ho); ~~~~~~~~^~ In file included from C:/MinGW/x86_64-w64-mingw32/include/windows.h:72, from InvertColors.cpp:1: InvertColors.cpp: In function 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)': InvertColors.cpp:76:10: error: expression list treated as compound expression in initializer [-fpermissive] HWND CreateWindowW( ^~~~~~~~~~~~~ InvertColors.cpp:76:10: error: invalid conversion from 'int' to 'HWND' {aka 'HWND__*'} [-fpermissive] E o código: #include <windows.h> #include <winuser.h> #include <stdio.h> const char g_szClassName[] = "ClassedaJanela"; int x1 = GetSystemMetrics(SM_XVIRTUALSCREEN); int y1 = GetSystemMetrics(SM_YVIRTUALSCREEN); int x2 = GetSystemMetrics(SM_CXVIRTUALSCREEN); int y2 = GetSystemMetrics(SM_CYVIRTUALSCREEN); int w = x2 - x1; int h = y2 - y1; int CapturaTelaInvertida(){ HDC telaDC = GetDC(NULL); HDC compDC = CreateCompatibleDC(telaDC); HBITMAP btm = CreateCompatibleBitmap(telaDC, w, h); HGDIOBJ obj = SelectObject(compDC, btm); BOOL ret = BitBlt(compDC, 0, 0, w, h, telaDC, x1, y1, NOTSRCCOPY); return btm; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hsti; switch(msg) { case WM_CREATE: hsti = CreateWindowW(L"Static", L"", WS_CHILD | WS_VISIBLE | SS_BITMAP, 0, 0, 1366, 768, hwnd, (HMENU) 1, NULL, NULL); SendMessage(hsti, STM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) CapturaTelaInvertida()); break; case WM_DESTROY: DeleteObject(CapturaTelaInvertida()); PostQuitMessage(0); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Sleep(500); WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); wc.lpszMenuName = NULL; wc.lpszClassName = "BasicWindow"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } HWND CreateWindowW( L"BasicWindow", L"MEMZ", WS_POPUP | WS_VISIBLE | WS_BORDER, 0, 0, 1366, 768, 0, 0, hInstance, 0); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "MEMZ", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); BOOL ShowWindow( HWND hWnd, int nCmdShow ); // Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
  4. Olá galera do Clube do Hardware! Eu estou fazendo um sistema operacional e eu quero no meu sistema operacional que, após ele executar as rotinas ele espere um tempo em segundos para ele executar as próximas rotinas que vem pela frente. Como vou fazer isso? Atenção: Eu estou usando o compilador NASM para compilar o sistema. Meu sistema operacional está assim:
  5. Deu mais um erro: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch] int y1 = GetSystemMetrics(SM_YVIRTUALSCREEN); ^~ In file included from C:/MinGW/x86_64-w64-mingw32/include/windows.h:72, from InvertColors.cpp:1: InvertColors.cpp: In function 'LRESULT WndProc(HWND, UINT, WPARAM, LPARAM)': InvertColors.cpp:26:45: error: cannot convert 'HBITMAP' {aka 'HBITMAP__*'} to 'LPCWSTR' {aka 'const wchar_t*'} hsti = CreateWindowW(L"Static", btm, ^~~ C:/MinGW/x86_64-w64-mingw32/include/winuser.h:2138:86: note: initializing argument 3 of 'HWND__* CreateWindowExW(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)' WINUSERAPI HWND WINAPI CreateWindowExW(DWORD dwExStyle,LPCWSTR lpClassName,LPCWSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam); ~~~~~~~~^~~~~~~~~~~~ InvertColors.cpp:31:49: error: 'hBitmap' was not declared in this scope (WPARAM) IMAGE_BITMAP, (LPARAM) hBitmap); ^~~~~~~ In file included from C:/MinGW/x86_64-w64-mingw32/include/windows.h:72, from InvertColors.cpp:1: InvertColors.cpp: In function 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)': InvertColors.cpp:72:10: error: expression list treated as compound expression in initializer [-fpermissive] HWND CreateWindowW( ^~~~~~~~~~~~~ InvertColors.cpp:72:10: error: invalid conversion from 'int' to 'HWND' {aka 'HWND__*'} [-fpermissive] E o Código: #include <windows.h> #include <winuser.h> #include <stdio.h> const char g_szClassName[] = "ClassedaJanela"; int x1 = GetSystemMetrics(SM_XVIRTUALSCREEN); int y1 = GetSystemMetrics(SM_YVIRTUALSCREEN); int x2 = GetSystemMetrics(SM_CXVIRTUALSCREEN); int y2 = GetSystemMetrics(SM_CYVIRTUALSCREEN); int w = x2 - x1; int h = y2 - y1; HDC telaDC = GetDC(NULL); HDC compDC = CreateCompatibleDC(telaDC); HBITMAP btm = CreateCompatibleBitmap(telaDC, w, h); HGDIOBJ obj = SelectObject(compDC, btm); BOOL ret = BitBlt(compDC, 0, 0, w, h, telaDC, x1, y1, NOTSRCCOPY); LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hsti; switch(msg) { case WM_CREATE: hsti = CreateWindowW(L"Static", btm, WS_CHILD | WS_VISIBLE | SS_BITMAP, 0, 0, 1366, 768, hwnd, (HMENU) 1, NULL, NULL); SendMessage(hsti, STM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hBitmap); break; case WM_DESTROY: DeleteObject(hBitmap); PostQuitMessage(0); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Sleep(500); WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); wc.lpszMenuName = NULL; wc.lpszClassName = "BasicWindow"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } HWND CreateWindowW( L"BasicWindow", L"MEMZ", WS_POPUP | WS_VISIBLE | WS_BORDER, 0, 0, 1366, 768, 0, 0, hInstance, 0); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "MEMZ", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); BOOL ShowWindow( HWND hWnd, int nCmdShow ); // Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
  6. Lucca, E Agora o que eu coloco no caminho da imagem? #include <windows.h> #include <winuser.h> #include <stdio.h> #define WM_CREATE 0x0001 const char g_szClassName[] = "ClassedaJanela"; int CapturaCorInvertida() { int x1 = GetSystemMetrics(SM_XVIRTUALSCREEN); int y1 = GetSystemMetrics(SM_YVIRTUALSCREEN); int x2 = GetSystemMetrics(SM_CXVIRTUALSCREEN); int y2 = GetSystemMetrics(SM_CYVIRTUALSCREEN); int w = x2 - x1; int h = y2 - y1; HDC telaDC = GetDC(NULL); HDC compDC = CreateCompatibleDC(telaDC); HBITMAP btm = CreateCompatibleBitmap(telaDC, w, h); HGDIOBJ obj = SelectObject(compDC, btm); BOOL ret = BitBlt(compDC, 0, 0, w, h, telaDC, x1, y1, NOTSRCCOPY); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hsti; switch(msg) { case WM_CREATE: LoadMyImage(); hsti = CreateWindowW(L"Static", L"", WS_CHILD | WS_VISIBLE | SS_BITMAP, 0, 0, WindowX(), WindowY(), hwnd, (HMENU) 1, NULL, NULL); SendMessage(hsti, STM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hBitmap); break; case WM_DESTROY: DeleteObject(hBitmap); PostQuitMessage(0); break; } return DefWindowProcW(hwnd, msg, wParam, lParam); } void LoadMyImage(void) { hBitmap = LoadImageW(NULL, L"", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Sleep(500); CapturaCorInvertida(); WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); wc.lpszMenuName = NULL; wc.lpszClassName = "BasicWindow"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } HWND CreateWindowW( L"BasicWindow", L"MEMZ", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_BORDER, 0, 0, 1366, 768, 0, 0, hInstance, 0); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "MEMZ", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); BOOL ShowWindow( HWND hWnd, int nCmdShow ); // Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
  7. #include <windows.h> #include <winuser.h> #include <stdio.h> #define WM_CREATE 0x0001 const char g_szClassName[] = "ClassedaJanela"; void CapturaCorInvertida(void) { int x1 = GetSystemMetrics(SM_XVIRTUALSCREEN); int y1 = GetSystemMetrics(SM_YVIRTUALSCREEN); int x2 = GetSystemMetrics(SM_CXVIRTUALSCREEN); int y2 = GetSystemMetrics(SM_CYVIRTUALSCREEN); int w = x2 - x1; int h = y2 - y1; HDC telaDC = GetDC(NULL); HDC compDC = CreateCompatibleDC(telaDC); HBITMAP btm = CreateCompatibleBitmap(telaDC, w, h); HGDIOBJ obj = SelectObject(compDC, btm); BOOL ret = BitBlt(compDC, 0, 0, w, h, telaDC, x1, y1, NOTSRCCOPY); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Sleep(500); CapturaCorInvertida(); WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); wc.lpszMenuName = NULL; wc.lpszClassName = "BasicWindow"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } HWND CreateWindowW( L"BasicWindow", L"MEMZ", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_BORDER, 0, 0, 1366, 768, 0, 0, hInstance, 0); bk = CreateWindowW( L"BasicWindow", L"MEMZ", WS_CHILD | WS_VISIBLE | SS_BITMAP, 0, 0, 1366, 768, 0, 0, hwnd, 0); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "MEMZ", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); BOOL ShowWindow( HWND hWnd, int nCmdShow ); // Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
  8. ________________________________________________________________________ Agora deu mais um erro: In file included from C:/MinGW/x86_64-w64-mingw32/include/windows.h:72, from vtmuv.cpp:1: vtmuv.cpp: In function 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)': vtmuv.cpp:69:10: error: expression list treated as compound expression in initia lizer [-fpermissive] HWND CreateWindowW( ^~~~~~~~~~~~~ vtmuv.cpp:69:10: error: invalid conversion from 'int' to 'HWND' {aka 'HWND__*'} [-fpermissive] vtmuv.cpp:82:5: error: 'bk' was not declared in this scope bk = CreateWindowW( ^~ In file included from C:/MinGW/x86_64-w64-mingw32/include/windows.h:72, from vtmuv.cpp:1: vtmuv.cpp:82:10: error: 'CreateWindowExW' cannot be used as a function bk = CreateWindowW( ^~~~~~~~~~~~~
  9. #include <windows.h> #include <winuser.h> #include <stdio.h> const char g_szClassName[] = "ClassedaJanela"; void CapturaCorInvertida(void) { int x1 = GetSystemMetrics(SM_XVIRTUALSCREEN); int y1 = GetSystemMetrics(SM_YVIRTUALSCREEN); int x2 = GetSystemMetrics(SM_CXVIRTUALSCREEN); int y2 = GetSystemMetrics(SM_CYVIRTUALSCREEN); int w = x2 - x1; int h = y2 - y1; HDC telaDC = GetDC(NULL); HDC compDC = CreateCompatibleDC(telaDC); HBITMAP btm = CreateCompatibleBitmap(telaDC, w, h); HGDIOBJ obj = SelectObject(compDC, btm); BOOL ret = BitBlt(compDC, 0, 0, w, h, telaDC, x1, y1, NOTSRCCOPY); // Salvando para a area de transferencia OpenClipboard(NULL); EmptyClipboard(); SetClipboardData(CF_BITMAP, btm); CloseClipboard(); // Deletando e liberando SelectObject(compDC, obj); DeleteDC(compDC); ReleaseDC(NULL, telaDC); DeleteObject(btm); } int main() { Sleep(500); CapturaCorInvertida(); return 0; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); wc.lpszMenuName = NULL; wc.lpszClassName = "BasicWindow"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } HWND CreateWindowW( "BasicWindow", L"MEMZ", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_BORDER, 0, 0, 1366, 768, 0, 0, hInstance, 0); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "MEMZ", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); // Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
  10. @Lucca Rodrigues Eu não consigo ultilizar a função CreateWIndowW porque dá esse erro: In file included from C:/MinGW/x86_64-w64-mingw32/include/windows.h:72, from vtmuv.cpp:1: vtmuv.cpp: In function 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)': vtmuv.cpp:85:10: error: expression list treated as compound expression in initia lizer [-fpermissive] HWND CreateWindowW( ^~~~~~~~~~~~~ vtmuv.cpp:85:10: error: invalid conversion from 'int' to 'HWND' {aka 'HWND__*'} [-fpermissive]
  11. mds eu consegui fazer isso mas lucca, também você pode colocar o código que você usou para eu usar no meu windows 7?
  12. o código que ele mandou de exemplo, 8.1.0, não sei
  13. No meu compilador (MinGW) esse código não funciona o que faço?
  14. Olá, Eu preciso que vocês me digam como eu vou fazer um programa que inverte as cores da tela do computador em c++ igual como o virus MEMZ faz. Eu pesquisei como que eu fazia no google, mas eu não achei o que eu queria, até encontrei um tópico aqui no Clube do Hardware, mas ele era de inverter as cores de uma imagem, que não era o que eu queria. O Payload da inversão das cores do MEMZ: //O Que eu coloco a mais aqui? #include <stdio.h> int main(){ //Agora o que eu coloco aqui para inverter as cores? }

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!