Jump to content

SUBIECTE NOI
« 1 / 5 »
RSS
Schimbare adresa DNS IPv4 pe rout...

Recomandare Barebone

Monede JO 2024

Suprasolicitare sistem electric
 CIV auto import

Mutare in MOZAMBIC - pareri, expe...

Scoatere antifurt airtag de pe ha...

Magnet in loc de clește pent...
 Cumparat/Locuit in apartament si ...

Pot folosi sistemul PC pe post de...

Sokol cu distorsiuni de cross-over

Filtru apa potabila cu osmoza inv...
 Kanal D va difuza serialul “...

Upgrade xiaomi mi11

securitate - acum se dau drept - ...

Farmacia Dr Max - Pareri / Sugest...
 

Prelucrare TAB win32

- - - - -
  • Please log in to reply
2 replies to this topic

#1
vitalusca

vitalusca

    Junior Member

  • Grup: Members
  • Posts: 26
  • Înscris: 23.08.2013
Salut!!!
Am asa problema: Trebuie sa desenez intr-o singura fereastra 3 figuri,
cu ajutorul tastelor +, -, ->, <-,  se misca, roteste, scalaeaza etc. figurile
Cu ajutorul tastei TAB trebuie sa schimb figura, SI Nu-mi reuseste de fel.
Va rog frumos sa ma ajutati daca este posibil.

Pun si codul sursa la etapa care am ajuns:

// KWnd.cpp
#include "KWnd.h"

KWnd::KWnd(LPCTSTR windowName, HINSTANCE hInst, int cmdShow,
   LRESULT (WINAPI *pWndProc)(HWND,UINT,WPARAM,LPARAM),
   LPCTSTR menuName, int x, int y, int width, int height,
   UINT classStyle, DWORD windowStyle, HWND hParent)
{
TCHAR szClassName[] = _T("KWndClass");

wc.cbSize     = sizeof(wc);
wc.style = classStyle;
wc.lpfnWndProc   = pWndProc;
wc.cbClsExtra  = 0;
wc.cbWndExtra    = 0;
wc.hInstance = hInst;
wc.hIcon   = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor    = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) CreateSolidBrush (RGB(194, 198, 203));
wc.lpszMenuName  = menuName;
wc.lpszClassName = szClassName;
wc.hIconSm    = LoadIcon(NULL, IDI_APPLICATION);

// Inregistrare class fereastra
if (!RegisterClassEx(&wc)) {
  TCHAR msg[] = _T("Cannot register class: ");
  _tcscat_s(msg, szClassName);
  MessageBox(NULL, msg, L"Error", MB_OK);
  return;
}

// Creare fereastra
hWnd = CreateWindow(szClassName, windowName, windowStyle,
  x, y, width, height, hParent, (HMENU)NULL, hInst, NULL);   

if (!hWnd) {
  TCHAR text[] = _T("Cannot create window: ");
  _tcscat_s(text, windowName);
  MessageBox(NULL, text, L"Error", MB_OK);
  return;
}

// Afisare fereastra
ShowWindow(hWnd, cmdShow);
}



// KWnd.h
#ifndef KWnd_H_INCLUDED
#define KWnd_H_INCLUDED

#include <windows.h>
#include <tchar.h>   //macrouri utile ex: _T
#include <math.h>


class KWnd {
public:
KWnd(LPCTSTR windowName, HINSTANCE hInst,
int cmdShow,LRESULT (WINAPI *pWndProc)(HWND,UINT,WPARAM,LPARAM),LPCTSTR menuName = NULL,int x = CW_USEDEFAULT, int y = 0,int width = CW_USEDEFAULT, int height = 0,
  UINT classStyle =  CS_HREDRAW | CS_VREDRAW,
  DWORD windowStyle = WS_OVERLAPPEDWINDOW,
  HWND hParent = NULL);

HWND GetHWnd() { return hWnd; }
protected:
HWND hWnd;
WNDCLASSEX wc;
};

#endif // KWnd_H_INCLUDED


//////////////////////////////////////////////////////////////////////
// main.cpp
#include "KWnd.h"
#include <stdio.h>
//#include "draw.h"
//#include "drawCube.cpp"


void drawTriangle(HDC hDC, bool hide);
void drawCube(HDC hDC, bool hide);

int x = 150;
int y = 250;
int pas = 5;
double unghi = 0.0;
double unghi_pas = 0.05;
double scale = 1.0;
double scaleFactor = 0.05;

#define Cube 1
#define Triangle 2
#define Romb 3
int figura_activa = Cube;



LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
///////////////////////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
KWnd mainWnd (L"PROIECT", hInstance, nCmdShow, WndProc);

// Ciclu de prelucarea mesaje
while (GetMessage(&msg, NULL, 0, 0))  {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
}

return msg.wParam;
}

///////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT ps;
HBRUSH hbrush;

    switch (msg) {
  hbrush=CreateSolidBrush(RGB(255,200,0));
  SelectObject(hDC,hbrush);

case WM_KEYDOWN :
  switch (wParam) {

    case VK_TAB:
hDC = GetDC(hWnd);
  
   if(figura_activa == 1)
   figura_activa = 2;
  


ReleaseDC(hWnd, hDC);
  
   return 0;
case VK_UP :
   hDC = GetDC(hWnd);
   //Draw(hDC, pt, true,  );
    // drawCube(hDC,true);
//drawTriangle(hDC,true);

   y -= pas;
   //drawCube(hDC,false);
   //drawTriangle(hDC,false);
   ReleaseDC(hWnd, hDC);

  
  return 0;
  case VK_DOWN :
   hDC = GetDC(hWnd);
   //drawCube(hDC,true);
   y += pas;
   //drawCube(hDC,false);
   ReleaseDC(hWnd, hDC);
  return 0;
  case VK_LEFT :
   hDC = GetDC(hWnd);
   //drawCube(hDC,true);
   x -= pas;
   //drawCube(hDC,false);
   ReleaseDC(hWnd, hDC);
  return 0;
  case VK_RIGHT :
   hDC = GetDC(hWnd);
   //drawCube(hDC,true);
   x += pas;
   //drawCube(hDC,false);
   ReleaseDC(hWnd, hDC);
  return 0;
  case 'q':
  case 'Q':
   hDC = GetDC(hWnd);
   //drawCube(hDC,true);
   unghi += unghi_pas;
   //drawCube(hDC,false);
   ReleaseDC(hWnd, hDC);
  return 0;
  case 'w':
  case 'W':
   hDC = GetDC(hWnd);
   //drawCube(hDC,true);
   unghi -= unghi_pas;
   //drawCube(hDC,false);
   ReleaseDC(hWnd, hDC);
  return 0;
  //----------------------scalare
  case 'k':
  case 'K':
   hDC = GetDC(hWnd);
   //drawCube(hDC,true);
   scale += scaleFactor;
   //drawCube(hDC,false);
   ReleaseDC(hWnd, hDC);
  return 0;
  case 'm':
  case 'M':
   hDC = GetDC(hWnd);
   //drawCube(hDC,true);
   scale -= scaleFactor;
   //drawCube(hDC,false);
   ReleaseDC(hWnd, hDC);
  return 0;



    }
    return 0;

    case WM_PAINT :
   hDC = BeginPaint (hWnd, &ps) ;
  
  // if (figura_activa == 1)
  //  drawCube(hDC,false);

  if (figura_activa == 1)
    drawTriangle(hDC,false);
  
   /*if (figura_activa == Romb)
  drawRomb(hdc,a,B);*/


  EndPaint (hWnd, &ps) ;
    return 0 ;
   case WM_DESTROY :
   PostQuitMessage (0) ;
   return 0 ;
}
   return DefWindowProc (hWnd, msg, wParam, lParam) ;
return 0;
}

void drawCube(HDC hDC, bool hide) {
   HPEN hPen;
   if (hide) {
  hPen = CreatePen(PS_SOLID, 5, RGB(194, 198, 203));
  SelectObject(hDC, hPen);
  SetBkColor(hDC, RGB(194, 198, 203));

   } else {
  hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
  SelectObject(hDC, hPen);
   }
  int p;
  p = 11;
   POINT puncte[11];

   puncte[0].x = x;
  puncte[0].y = y;

  puncte[1].x = x+100;
  puncte[1].y = y;

  puncte[2].x = x+130;
  puncte[2].y = y-30;

  puncte[3].x = x+30;
  puncte[3].y = y-30;

   puncte[4].x = x;
  puncte[4].y = y;

   puncte[5].x = x;
  puncte[5].y = y+100;

   puncte[6].x = x+100;
  puncte[6].y = y+100;

   puncte[7].x = x+100;
  puncte[7].y = y;

   puncte[8].x = x+130;
  puncte[8].y = y-30;

   puncte[9].x = x+130;
  puncte[9].y = y+70;

   puncte[10].x = x+100;
  puncte[10].y = y+100;

   int x1 = x+25,y1 = y+25;
  for(int i = 0;i<p;i++) {
    puncte[i].x = (int)((puncte[i].x-x1)*cos(unghi)-(puncte[i].y-y1)*sin(unghi)+x1);
    puncte[i].y = (int)((puncte[i].x-x1)*sin(unghi) + (puncte[i].y-y1)*cos(unghi)+y1);
  }

   for(int i = 0;i<p;i++) {
puncte[i].x = (int)((puncte[i].x - 200)* scale + 200);
  puncte[i].y = (int)((puncte[i].y - 200) * scale + 200);
   }
  
   Polyline(hDC,puncte,p);
  DeleteObject(hPen);
}

void drawTriangle(HDC hDC, bool hide) {
   HPEN hPen;
   if (hide) {
  hPen = CreatePen(PS_SOLID, 5, RGB(194, 198, 203));
  SelectObject(hDC, hPen);
  SetBkColor(hDC, RGB(194, 198, 203));

   } else {
  hPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 0));
  SelectObject(hDC, hPen);
   }
  int p;
  p = 4;
   POINT puncte[4];

   puncte[0].x = x + 400;
  puncte[0].y = y;

  puncte[1].x = x + 300;
  puncte[1].y = y + 100;

  puncte[2].x = x + 500;
  puncte[2].y = y + 100;

  puncte[3].x = x + 400;
  puncte[3].y = y ;

   int x1 = x + 25,y1 = y + 25;
  for(int i = 0;i<p;i++) {
    puncte[i].x = (int)((puncte[i].x-x1)*cos(unghi)-(puncte[i].y-y1)*sin(unghi)+x1);
    puncte[i].y = (int)((puncte[i].x-x1)*sin(unghi) + (puncte[i].y-y1)*cos(unghi)+y1);
  }

   for(int i = 0;i<p;i++) {
puncte[i].x = (int)((puncte[i].x - 200)* scale + 200);
  puncte[i].y = (int)((puncte[i].y - 200) * scale + 200);
   }
  
   Polyline(hDC,puncte,p);
  DeleteObject(hPen);
}


#2
EnachescuAlin

EnachescuAlin

    Active Member

  • Grup: Members
  • Posts: 1,008
  • Înscris: 08.07.2013
Crezi ca se uita cineva peste codul tau?

#3
vitalusca

vitalusca

    Junior Member

  • Grup: Members
  • Posts: 26
  • Înscris: 23.08.2013
Probabil ca nu se uita nimeni. Dar eram in impas.

DEJA AM REZOLVAT!!!

Anunturi

Chirurgia endoscopică a hipofizei Chirurgia endoscopică a hipofizei

"Standardul de aur" în chirurgia hipofizară îl reprezintă endoscopia transnazală transsfenoidală.

Echipa NeuroHope este antrenată în unul din cele mai mari centre de chirurgie a hipofizei din Europa, Spitalul Foch din Paris, centrul în care a fost introdus pentru prima dată endoscopul în chirurgia transnazală a hipofizei, de către neurochirurgul francez Guiot. Pe lângă tumorile cu origine hipofizară, prin tehnicile endoscopice transnazale pot fi abordate numeroase alte patologii neurochirurgicale.

www.neurohope.ro

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Forumul Softpedia foloseste "cookies" pentru a imbunatati experienta utilizatorilor Accept
Pentru detalii si optiuni legate de cookies si datele personale, consultati Politica de utilizare cookies si Politica de confidentialitate