|
I suppose you could subtract the height of the desktop's client area (i.e., SystemParametersInfo(SPI_GETWORKAREA, ...) ) from the height of the screen (i.e., GetSystemMetrics(SM_CYSCREEN) ). The difference would be the height of the taskbar. For an MFC solution, something like:
CWnd *pTaskbar = CWnd::FindWindow("Shell_TrayWnd", NULL);
CRect rc;
pTaskbar->GetWindowRect(rc);
int nWidth = rc.Width();
int nHeight = rc.Height();
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Call SHAppBarMessage(ABM_GETTASKBARPOS) . No sense searching through windows when there's an API that does exactly what you want.
|
|
|
|
|
According to the API description you have to pass the hwnd of your taskbar. :/
SHAppBarMessage(ABM_QUERYPOS, pabd);
pabd
A pointer to an APPBARDATA structure. The uEdge member specifies a screen edge, and the rc member contains the proposed bounding rectangle. When the SHAppBarMessage function returns, rc contains the approved bounding rectangle. You must specify the cbSize, hWnd, uEdge, and rc members when sending this message; all other members are ignored.
Source: msdn
|
|
|
|
|
How can i test with C++ if i had the mode "do not display content while moving windows" in windows desk properties settings.
To get this mode:
-right click on windows desktop, choose general settings
-Tab "appearance"
-clic on Effects.
|
|
|
|
|
Have a look at the MSDN documents for the SystemParametersInfo[^] API - the SPI_GETDRAGFULLWINDOWS flag in particular.
Your code should end up something like this:
BOOL bResult = FALSE;
if( SystemParametersInfo( SPI_GETDRAGFULLWINDOWS, 0, & bResult, 0 ) )
{
if( bResult )
MessageBox( NULL, TEXT( "on" ), 0, 0 );
else
MessageBox( NULL, TEXT( "off" ), 0, 0 );
}
|
|
|
|
|
|
Rather than starting a new thread, I will attach my question here since it is related.
Is it possible to enable/disable this setting for a single application at runtime? Ie, I do not want my app to display it's contents while sizing, but I don't want to change the registry as it would effect all other windows.
|
|
|
|
|
Windows itself doesn't provide a way to disable full window drag for a specific application / window. The only way I can think of would be to intercept the windows move / resize messages and disable the effect on the fly using SPI_SETDRAGFULLWINDOWS which is really a hack and definately not recommended.
Having just done some digging around this[^] article touches on the subject of drawing your own drag boxing, whilst not totally what your after you could to use that as a good starting pointing.
|
|
|
|
|
Thanks for the link. It has put me a little closer to achieving my goal. Though if I can get my GDI routines to work faster I may not even need to draw a drag box.
|
|
|
|
|
dll problem,help me
i create dll project ,the dll is Use MFC in a Static Library
i hope exe call ListCtrl class from dll
==================DLL====================
<<<<<<<<<<listctrl.h>>>>>>>>>>>>>>>
#pragma once
class AFX_EXT_CLASS ListCtrl :public CListCtrl
{
public:
__declspec(dllexport) ListCtrl();
__declspec(dllexport) ~ListCtrl();
public:
DECLARE_MESSAGE_MAP();
public:
afx_msg void OnNMClick(NMHDR *pNMHDR, LRESULT *pResult);
};
<<<<<<<<<<<listctrl.cpp>>>>>>>>>>>
#include "Stdafx.h"
#include "ListCtrl.h"
ListCtrl::ListCtrl()
{}
ListCtrl::~ListCtrl()
{}
BEGIN_MESSAGE_MAP(ListCtrl,CListCtrl)
ON_NOTIFY_REFLECT(NM_CLICK, &ListCtrl::OnNMClick)
END_MESSAGE_MAP()
void ListCtrl::OnNMClick(NMHDR *pNMHDR, LRESULT *pResult)
{
AfxMessageBox(_T("OK"));
*pResult = 0;
}
=====================EXE============================
i Create Exe,the exe is Use MFC in a Static Library
<<<<<<<<<<<testdlg.h>>>>>>>>>>>>
#pragma comment(lib,"Dll.lib")
#include "ListCtrl.h"
class TestDlg : public CDialog
{
DECLARE_DYNAMIC(TestDlg)
public:
TestDlg(CWnd* pParent = NULL); // standard constructor
virtual ~TestDlg();
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
ListCtrl m_ListCtrl;
};
<<<<<<<<<<<<<<<testdlg.cpp>>>>>>>>>>
#include "stdafx.h"
#include "Test.h"
#include "TestDlg.h"
IMPLEMENT_DYNAMIC(TestDlg, CDialog)
TestDlg::TestDlg(CWnd* pParent /*=NULL*/)
: CDialog(TestDlg::IDD, pParent)
{}
TestDlg::~TestDlg()
{}
void TestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_ListCtrl);
}
BEGIN_MESSAGE_MAP(TestDlg, CDialog)
ON_BN_CLICKED(IDOK, &TestDlg::OnBnClickedOk)
END_MESSAGE_MAP()
======================
the exe project call ListCtrl from dll project
Mouse click the m_ListCtrl window,error
why????
help me,thank you
Blog:
http://360.yahoo.com/rxgmoral
|
|
|
|
|
rxgmoral wrote: error
why????
1) speak proper englisk
2) provide useful informations : What error message ? how exactly did it happen ?
|
|
|
|
|
You asked the same question - please don't keep reposting the same question.
You're probably not getting an answer as you don't really give much info. Today you're getting an error. What is the error? Have you tried stepping through in a debugger when you click your list control? What happens?
|
|
|
|
|
|
Hi, i'm learning c++ and i'm having a problem using a class.
My class is defined like this:
// ****************************************************
class CTest
{
public:
CString *sName;
CTest();
~CTest();
};
CTest::CTest()
{
this->sName=NULL;
}
CTest::~CTest()
{
if (this->sName!=NULL)
delete[] (this->sName);
}
// ****************************************************
And used like this:
CTest test;
test.sName = new CString("Just a test");
It works, but when test is destructed it gives me an unhandled exception error. I though that when you used a pointer to something like an array, you had to use delete[]. I've tried without the [] and it works, but i think there will be a memory leak, no?
Hope someone can explain this to me.
Thanks in advance,
Rad.
|
|
|
|
|
new -> use delete
new[] -> use delete[]
|
|
|
|
|
Thanks for the quick reponse! I was worried about the memory leaks . Thank you.
|
|
|
|
|
Just a question: why are you using a pointer ? You know that CString is a class and you don't need to work with it the same way as a standard char array ?
You can simply have declared it CString sName and use sName. The CString class will manage everything for you.
Also, on a side note:
this->sName=NULL;
I never understood why people were using the this pointer everytime they access a member variable
|
|
|
|
|
Well, you were right
I don't need to use a pointer. I'm still thinking in a "C way", and, as I didn't want to use more memory than necessary I thought that the best way was to use pointers. After your question I've tried and it looks like the CString class implements all that I need.
And, about the other question... hey, I'm learning!
Thanks for the suggestions,
Rad.
|
|
|
|
|
The C++ way is: always use objects or references unless you need to use pointers. If you must use pointers then prefer smart pointers. Basically, make life as easy for yourself as possible. Only make it difficult when you have to.
Kevin
|
|
|
|
|
Cedric Moonen wrote: I never understood why people were using the this pointer everytime they access a member variable
matter of readability of the code... i use it also but muchfor member functions (for data members, the leading m_ already tells it's a member of the class)
|
|
|
|
|
I don't find that very readable in fact
For member variables, I use the leading m_ as you do. But for member functions, in fact, as I almost never have global functions,I don't need the this .
|
|
|
|
|
i don't use Globals either, but that's a matter of taste i believe... you don't like it, i do... maybe a poll could tell us which rate of the population here uses this syntax
|
|
|
|
|
Cedric Moonen wrote: in fact, as I almost never have global functions,
By "global functions", do you mean you never have functions outside of classes, or that all your standalone functions are in their own namespace?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: By "global functions", do you mean you never have functions outside of classes, or that all your standalone functions are in their own namespace?
I mean I almost never have functions outside of classes. Of course, I still call global functions from the API (I didn't think of that when I posted my message ) but in general you I recognize them easily.
|
|
|
|
|
Ah, I see. Now my question would be, why the hell not!? You force yourself into the limitations of OOD by choice? There are actually some functions you can't write as member functions (at least not and have them functional).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|