|
|
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
|
|
|
|
|
Zac Howland wrote: You force yourself into the limitations of OOD by choice?
Not at all. In fact, I have in general some functions that are global but they are limited (and then, I use namespace if it is possible to group them). In fact, I never came to a situation like: "ok, I have this function and I don't know in which class to put it, let's make a class to wrap it".
|
|
|
|
|
Cedric Moonen wrote: Not at all. In fact, I have in general some functions that are global but they are limited (and then, I use namespace if it is possible to group them). In fact, I never came to a situation like: "ok, I have this function and I don't know in which class to put it, let's make a class to wrap it".
Ah, so you do use globals behind a namespace then? You had me worried there for a second
Generally, when I'm writing classes, I try to not put as many functions as possible (that make sense, obviously) inside the class. They will be "packaged" with the class (usually defined in the same header file and part of the same namespace), but not actually be in the class.
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
|
|
|
|
|
Cedric Moonen wrote: I never understood why people were using the this pointer everytime they access a member variable
Honestly, I find that most people use it because typing "this->" will trigger Intellisense so they don't have to type out the whole member name they are trying to access (e.g. laziness).
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: I find that most people use it because typing "this->" will trigger Intellisense
And typing all that and scrolling through list of possible auto completes is more efficient?
|
|
|
|
|
Mark Salsbery wrote: ...and scrolling through list of possible auto completes...
If the list even shows up.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|