Click here to Skip to main content
15,890,973 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWin32 Structures Pin
Richard Andrew x6414-Mar-21 9:52
professionalRichard Andrew x6414-Mar-21 9:52 
AnswerRe: Win32 Structures Pin
Mircea Neacsu14-Mar-21 10:22
Mircea Neacsu14-Mar-21 10:22 
GeneralRe: Win32 Structures Pin
Richard Andrew x6414-Mar-21 10:32
professionalRichard Andrew x6414-Mar-21 10:32 
GeneralRe: Win32 Structures Pin
Mircea Neacsu14-Mar-21 10:36
Mircea Neacsu14-Mar-21 10:36 
AnswerRe: Win32 Structures Pin
11917640 Member 17-Mar-21 3:01
11917640 Member 17-Mar-21 3:01 
GeneralRe: Win32 Structures Pin
Richard Andrew x6417-Mar-21 9:20
professionalRichard Andrew x6417-Mar-21 9:20 
GeneralRe: Win32 Structures Pin
11917640 Member 17-Mar-21 19:19
11917640 Member 17-Mar-21 19:19 
QuestionZoom image on mouse position Pin
Gopi Nath12-Mar-21 0:20
Gopi Nath12-Mar-21 0:20 
Hello,

I am displaying an image in a static control (in a dialog) and trying to stretch according to the zoom factor on mouse position. Zoom on mouse position is working fine, but the image is not fitting inside the static control, going all over the dialog.

Below is the code.

C++
// source image
	Gdiplus::Bitmap *gpBitmap = new Gdiplus::Bitmap(mImagePath);

	int origW = gpBitmap->GetWidth(); // 5298 - original width
	int origH = gpBitmap->GetHeight(); // 2728 - original height

	// destination rectangle
	RECT rcVPC;
	GetClientRect(hWnd, &rcVPC); // 501 X 255 - size of the static control
	HDC hDc = GetDC(hWnd);

	float perW = (float)rcVPC.right / (float)origW;
	float perH = (float)rcVPC.bottom / (float)origH;
		
	int newW = origW * perW * mVPZoomFactor; // starting factor is 1.0 and multiplying with 1.2 with each zoom
	int newH = origH * perH * mVPZoomFactor;

	Gdiplus::Bitmap *bmpResized = new Gdiplus::Bitmap(newW, newH, gpBitmap->GetPixelFormat());
	Gdiplus::Graphics *graphics = new Gdiplus::Graphics(bmpResized);
	graphics->DrawImage(gpBitmap, 0, 0, newW, newH);
	
	int zoomWidth = (int)(0.5 + newW * mVPZoomFactor);
	int zoomHeight = (int)(0.5 + newH * mVPZoomFactor);

	//Find the position "factor"
	double dXFactor = (double)rcVPC.right / stX; // stX, stY - mouse position on zoom
	double dYFactor = (double)rcVPC.bottom / stY;

	//Find the origin
	int left = stX - zoomWidth / dXFactor;
	int right = stY - zoomHeight / dYFactor;

	HBRUSH   hB = GetSysColorBrush(COLOR_3DDKSHADOW);

	FillRect(hDc, &rcVPC, hB);

	HDC hdcMem = CreateCompatibleDC(hDc);

	bmpResized->GetHBITMAP(0, &hBmpVPCanvas);

	HBITMAP oldBmp = (HBITMAP)SelectObject(hdcMem, hBmpVPCanvas);

	//use StretchBlt
	StretchBlt(hDc, left, right, zoomWidth, zoomHeight, hdcMem, 0, 0, newW, newH, SRCCOPY);

	SelectObject(hdcMem, oldBmp);

	DeleteDC(hdcMem);

	delete gpBitmap;



Can anyone help me, what i am doing wrong?

Regards,
Gopinath.
AnswerRe: Zoom image on mouse position Pin
Richard MacCutchan12-Mar-21 1:28
mveRichard MacCutchan12-Mar-21 1:28 
GeneralRe: Zoom image on mouse position Pin
Gopi Nath14-Mar-21 20:34
Gopi Nath14-Mar-21 20:34 
QuestionSelect TRACE functions based on both a variable and a #define? Pin
arnold_w11-Mar-21 5:31
arnold_w11-Mar-21 5:31 
AnswerRe: Select TRACE functions based on both a variable and a #define? Pin
Richard MacCutchan11-Mar-21 6:11
mveRichard MacCutchan11-Mar-21 6:11 
GeneralRe: Select TRACE functions based on both a variable and a #define? Pin
arnold_w11-Mar-21 7:07
arnold_w11-Mar-21 7:07 
GeneralRe: Select TRACE functions based on both a variable and a #define? Pin
Richard MacCutchan11-Mar-21 23:11
mveRichard MacCutchan11-Mar-21 23:11 
GeneralRe: Select TRACE functions based on both a variable and a #define? Pin
arnold_w12-Mar-21 0:54
arnold_w12-Mar-21 0:54 
GeneralRe: Select TRACE functions based on both a variable and a #define? Pin
Richard MacCutchan12-Mar-21 1:22
mveRichard MacCutchan12-Mar-21 1:22 
GeneralRe: Select TRACE functions based on both a variable and a #define? Pin
arnold_w12-Mar-21 1:51
arnold_w12-Mar-21 1:51 
GeneralRe: Select TRACE functions based on both a variable and a #define? Pin
Richard MacCutchan12-Mar-21 2:43
mveRichard MacCutchan12-Mar-21 2:43 
QuestionMFC: CMFCPropertysheet CMFCPropertypage Pin
Member 1325158810-Mar-21 19:35
Member 1325158810-Mar-21 19:35 
AnswerRe: MFC: CMFCPropertysheet CMFCPropertypage Pin
Victor Nijegorodov10-Mar-21 20:21
Victor Nijegorodov10-Mar-21 20:21 
QuestionCMFCToolTipCtrl doen't enter OnPaint when I use it in my self-draw CTreeCtrl Pin
Member 1488267128-Feb-21 15:52
Member 1488267128-Feb-21 15:52 
AnswerRe: CMFCToolTipCtrl doen't enter OnPaint when I use it in my self-draw CTreeCtrl Pin
Randor 4-Mar-21 10:33
professional Randor 4-Mar-21 10:33 
AnswerRe: CMFCToolTipCtrl doen't enter OnPaint when I use it in my self-draw CTreeCtrl Pin
Victor Nijegorodov4-Mar-21 20:39
Victor Nijegorodov4-Mar-21 20:39 
QuestionMFC Dialog Based App Scaling Problem Pin
acerunner31626-Feb-21 6:28
acerunner31626-Feb-21 6:28 
AnswerRe: MFC Dialog Based App Scaling Problem Pin
RedDk26-Feb-21 7:22
RedDk26-Feb-21 7:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.