|
Sorry u right I was looking in the wrong place
Thanks
|
|
|
|
|
Why are all posts expanded now by default?
It is so ugly and I can see nothing except “HOW TO ANSWER A QUESTION”.
Could you change it to previous style? Or I have to leave.
.
|
|
|
|
|
The forum is the same as it's always been. Did you try clearing your cache?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Kidding!
Veni, vidi, vici.
|
|
|
|
|
Check the "Layout" drop down above the messages.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
HI,
I have a application similar to auto cad, in which we can draw line, circle, etc in client area using mouse or command.
Now i need to add a feature, so that the users of this application should be able to pan their drawings in client area using mouse left button. (like one in auto cad or pdf reader). I can use win32 API or MFC to achieve this.
It well be great of some one can help me in this regard, with some sample code.
Thanks in Advance
|
|
|
|
|
You just need to add code to your mouse handler to capture the amount of movement and use that information to adjust a variable which tells your program how far to the left or right the window should be moved. Then call InvalidateRect() [^] to tell the system that your window needs repainting. In your OnPaint() handler you use the stored variable to repaint that part of your data that falls within the physical window.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
ok, after getting x and y coordinates which API should I use to reset the x and y coordinates?
Thank you.
|
|
|
|
|
Member 9353776 wrote: after getting x and y coordinates which API should I use to reset the x and y coordinates? What do you mean by this? As I said in my reply, your program needs to capture the mouse movement and adjust the x and y values by the number of pixels moved. In your OnPaint() function you will be copying some part of your image onto the application's window. I assume the image (drawing) is larger than the window on which it is being drawn, so you just select the top left point from which to start based on the x and y values previously captured.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
You may also like to read this section of the GDI reference[^], which helps to visualise how this sort of problem can be addressed.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
We can achieve this. Please understand the below simple concept with respect to CAD or any drafting utility. We have 2 view perspective always.
1. the world window
2. the view port window. (this is what you need to add in your program)
The above can be best understood with the this example: Assume you are taking photograph of a flower in a park. Now, we focus only the flower in the view finder of your camera, and the park in this case forms the world around the flower. So in this case the park becomes the world window and the flower becomes the view window.
Similarly the whole drawing in your application is the world window whereas the part of the drawing that is shown to the end user is the view window. You have to make use of the SetViewportOrg method in your application. Please read this http://msdn.microsoft.com/en-us/library/46t66w7t.aspx[^]. Let me know if you need more help, I have done this before but unfortunately cannot find the source for it...
Sunil
|
|
|
|
|
sunilkpv wrote: the park becomes the world window and the flower becomes the view window. Nice analogy,
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
|
Hi Sunil,
Thank you very much for your information.
It will be a great help if you can help me with sample code.
-Maha
|
|
|
|
|
On the lookout for the code I had developed. Will send it ASAP
Sunil
|
|
|
|
|
This question is a duplicate of this: http://www.codeproject.com/Messages/4336758/How-to-pan-client-area-of-a-window-using-Cplusplus.aspx[^]
My detailed answer to it: http://www.codeproject.com/Messages/4337474/Re-How-to-pan-a-window-using-Cplusplus-VCplusplus-.aspx[^]
I recommended this minimal program to modify to implement your panning: Using SetCapture() and ReleaseCapture() correctly (usually during a drag n' drop operation).[^]
And here is the modified version of the recommended source:
main.cpp:
#include <windows.h>
HINSTANCE g_hInstance = (HINSTANCE)GetModuleHandle(NULL);
HWND g_hMainWnd = NULL;
bool g_MovingMainWnd = false;
POINT g_OrigCursorPos;
POINT g_PanStartIconPos;
HICON g_Icon = LoadIcon(NULL, IDI_EXCLAMATION);
POINT g_IconPos = { 0, 0 };
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_LBUTTONDOWN:
if (GetCursorPos(&g_OrigCursorPos))
{
RECT rt;
GetWindowRect(hWnd, &rt);
g_PanStartIconPos.x = g_IconPos.x;
g_PanStartIconPos.y = g_IconPos.y;
g_MovingMainWnd = true;
SetCapture(hWnd);
SetCursor(LoadCursor(NULL, IDC_SIZEALL));
}
return 0;
case WM_LBUTTONUP:
ReleaseCapture();
return 0;
case WM_CAPTURECHANGED:
g_MovingMainWnd = (HWND)lParam == hWnd;
return 0;
case WM_MOUSEMOVE:
if (g_MovingMainWnd)
{
POINT pt;
if (GetCursorPos(&pt))
{
g_IconPos.x = g_PanStartIconPos.x + (pt.x - g_OrigCursorPos.x);
g_IconPos.y = g_PanStartIconPos.y + (pt.y - g_OrigCursorPos.y);
InvalidateRect(hWnd, NULL, TRUE);
}
}
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
if (HDC dc = BeginPaint(hWnd, &ps))
{
DrawIcon(dc, g_IconPos.x, g_IconPos.y, g_Icon);
EndPaint(hWnd, &ps);
}
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
bool CreateMainWnd()
{
static const char CLASS_NAME[] = "MainWndClass";
WNDCLASS wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = g_hInstance;
wc.lpfnWndProc = &MainWndProc;
wc.lpszClassName = CLASS_NAME;
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
if (!RegisterClass(&wc))
return false;
g_hMainWnd = CreateWindowEx(
0,
CLASS_NAME,
"Main Window",
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, 300, 200,
NULL,
NULL,
g_hInstance,
NULL
);
return true;
}
int main()
{
if (!CreateMainWnd())
return -1;
ShowWindow(g_hMainWnd, SW_SHOW);
UpdateWindow(g_hMainWnd);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
|
|
|
|
|
Hi,
I have tried the logic you have given it is not working as I need.
It will be a great help if you can provide me modified sample code to pan the client area of a window.
|
|
|
|
|
No one can help you if you don't know what you wanna achieve.
|
|
|
|
|
(VS2008, MFC, Feature-Pack, also on VS2012)
I'm trying to not display the description part of a tooltip in a MFC application.
The description part is, I assume, the 2nd line of the default tooltip.
This is what I tried to do (in a straighforward wizard generated MFC application)
InitTooltipManager();
CMFCToolTipInfo ttParams;
ttParams.m_bVislManagerTheme = TRUE;
ttParams.m_bDrawDescription = FALSE; CTooltipManager* tooltipManager = theApp.GetTooltipManager();
tooltipManager->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
I would assume that the m_bDrawDescription in the struct, and the call to SetTooltipParams would change the whole behavior of the tooltips of the application, but it does not, when those lines are added, nothing seems to changed.
When debugging, the field is (re)set to TRUE.
Am I missing something ?
Thanks.
Watched code never compiles.
|
|
|
|
|
I have an SDI application with view based on CFormView, where I layed a CListCtrl control ... on this control I try to catch OnKeyup event, but is available for mapping only OnKeydown event :
ON_NOTIFY(LVN_KEYDOWN, IDC_LIST1, OnKeydownList1)
void CTestListView::OnKeydownList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_KEYDOWN* pLVKeyDown = (LV_KEYDOWN*)pNMHDR;
*pResult = 0;
}
I try to modify LVN_KEYDOWN event in LVN_KEYUP, but there are not going ... my question is, how can I catch OnKeyup event on CListCtrl layered on CFormView ? It is not posible ?
Thank you.
modified 20-Aug-12 12:18pm.
|
|
|
|
|
If [this] still fails then maybe this?
WM_KEYUP Instead of LVN_KEYUP .
BEGIN_MESSAGE_MAP(CCeListCtrl, CListCtrl)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_KEYDOWN()
ON_WM_KEYUP()
END_MESSAGE_MAP()
void CCeListCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
switch (nChar) {
case VK_RETURN:
break;
}
CListCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CCeListCtrl::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) {
switch (nChar) {
case VK_RETURN:
break;
}
CListCtrl::OnKeyUp(nChar, nRepCnt, nFlags);
}
|
|
|
|
|
Hello Friends
creating a mFC project. Saving a image in bmp,for that I am using BITMAPINFOHEADER.
In Debug build,its working fine. But in release Build, BITMAPINFOHEADER fields are not accepting values that I am putting,it is still showing some garbage value.
Do I need to change in properties for release build ?
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
How do you check the values in Release? I hope not via debugger?
|
|
|
|
|
Hi
we cn debug in release build too.
|
|
|
|
|
Release builds usually optimize and this makes the debugger go wrong often.
If you want to see the values in Release it's probably better to use other means, writing them to a file or other external resource/tool.
|
|
|
|
|