|
|
Thx a lot Michael & Tom!
Sometimes it's embarrassing what question I ask,
but this tiny function would have kept me busy for a while!
|
|
|
|
|
Anonymous wrote:
Sometimes it's embarrassing what question I ask,
Luckily you were anonymous, right
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Nish [BusterBoy] wrote:
Luckily you were anonymous, right
got me
cheers
|
|
|
|
|
You're welcome. Just make sure that you understand that these functions will return different values and so deciding which one to use is going to be based on what you're trying to do.
Regarding positioning (x,y coordinates), the GetWindowRect returns the windows position relative to the overal screen. You can take the returned CRect and use it in a call to ScreenToClient to get the coordinates relative to the control's parent (e.g., the dialog). The GetClientRect will always return 0 and 0 for top and left.
Regarding sizing (cx,cy coordinates) the GetWindowRect size is based on the overall control (including its frame) while the GetClientRect is for getting the control's client area. Therefore GetClientRect will not include the size of the overall window and will usually be a bit smaller than the values returned from GetWindowRect (usually 4 pixels in the case of the default listbox).
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
Wow, that was very detailed. I have to say thx again!
Hm, I did use GetClientRect() in my case, since I wanted to know the width of my owner draw control (client area). Works fine now.
|
|
|
|
|
Hi.
Is there a way to set the margins in a CEditView view class to stay permanent? In the program I am working on, I can set the margin in OnEnSetFocus, however, if the user starts a new document, the margin resets to its default. The default margin makes it difficult for the user to see where the text being since it is so close to the left wall of the frame.
Here is the code I use to set the margin in OnEnSetFocus:
-----
void CMyAppView::OnEnSetfocus()
{
CEdit &rE = GetEditCtrl();
DWORD dwMargins = rE.GetMargins();
rE.SetMargins(3, HIWORD(dwMargins))
...
}
-----
Thanks,
Kuphryn
|
|
|
|
|
Is there a way to monitor a control (TreeView) from another program(AIM) to see if it has changed?
|
|
|
|
|
The best way is to create an application hook, and subclassing the parent window of the control, or the control itself ( depending on your needs!) in the hook function.
P.S: Take a look at the Hooks topic on the sdk docs
don´t worry drink happy
|
|
|
|
|
You can use WM_COPYDATA, that way you can also indicate something about what the new selection is.
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
I have downloaded the IE Security Manger sample (http://download.microsoft.com/download/ie5/secumgr/1/w9xnt4/en-us/Secumgr.exe [new window]) and it works without problem (prevents scripts/ActiveX/etc. in hosted WebBrowser).
However, I copied the custsite.h and custsite.cpp files into my project and removed the references to the dialog used in the sample. These files provide an extended COleControlSite and COccManager. I replaced the use of the dialog variables from the sample with global variables in my project.
Unfortunately in my project I get the following linker error when trying to build it in to my project:
custsite.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_INTERFACEMAP const COleControlSite::interfaceMap" (?interfaceMap@COleControlSite@@1UAFX_INTERFACEMAP@@B)
Please can someone explain why and how to fix it. I've looked everywhere to try and find it and I can't
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Hey Guys
I have been trying to export a class from a DLL for ages now and had little luck could someone post a quick example or tutorial on how to export a class.
Peter
|
|
|
|
|
This example was generated by the app wizards for a DLL.
Here is the header file:
#ifdef EXAMPLE_EXPORTS
#define EXAMPLE_API __declspec(dllexport)
#else
#define EXAMPLE_API __declspec(dllimport)
#endif
class EXAMPLE_API CExample {
public:
CExample(void);
};
extern EXAMPLE_API int nExample;
EXAMPLE_API int fnExample(void);
Here is the cpp file:
#include "stdafx.h"
#include "example.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
EXAMPLE_API int nExample=0;
EXAMPLE_API int fnExample(void)
{
return 42;
}
CExample::CExample()
{
return;
}
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
class AFX_EXT_CLASS CMyClass
{
...
}
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
When using the 'Properties' window in Visual C++ .Net and adding a handler for a Windows message (or overriding a virtual function), the VC++ .NET IDE adds the prototype as a 'public:' member.
This is a pain since I then have to go and cut and paste it into the 'protected:' section of my class def.
Does anyone know how to get the IDE to put it in the protected section for me like VC 6 used to do?
It makes no sense to me that a WM_LBUTTONDOWN handler be made public: by default!
|
|
|
|
|
Where should I post my TurboC++ / ASM / BIOS question?
I need a way to wake up the BIOS chip on an AGP card under DOS environment.
Can anyone help ??
Thank you!
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Oh, damn I accidentally postd this in the Lounge...now heres it is. I'd appreciate ny help.
Can somebody help me. I'm trying to create an array of pointers. I'd do something like this:
int *array[SIZE];
But the array's large so I'd like to use the _new_ operator. How do I do that?
I've tried the following without luck:
int ** array = new int[size];
int * array = new *int[size];
Plz help
|
|
|
|
|
int *array[SIZE];
for(int i=0;i<SIZE;i++)
array[i] = new int;
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
You were close:
int **array = new int*[SIZE];
That will allocate an array of integer pointers that has SIZE number of elements.
Just for everyone's knowledge, to access the pointers in this new array, you will need to do something like this:
int a = 10;
int b = 20;
int c = 30;
array[0] = &a;
array[1] = &b;
array[2] = new int;
*array[2] = 50;
array[3] = new int[10];
array[3][0] = 100;
just remember to delete any memory that you allocate, even in the pointers inside of your allocated array.
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Some day I asked Bjarne Stroustrup a question to dynamically allocating square array ( 2 X 2 or 3 X 3 or 10 X 10 ... ), He told me to use vector!
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
He's a wise man.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
His way is nice!
But finally I approached my goal via a template class that wraps a low-level 2d int array.
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Hi.
I would like to create a generic class that wraps around, say, an API function. I need a way to pass into a function parameters such as FEATURE1 | FEATURE3. I believe that requires the use of bitwise AND, OR, and NOT similar to MFC programming style.
For example:
-----
// call function to initialize variables
SetVariableA(FEATURE1 | FEATURE 3) // I want feature1 and feature3
-----
Here is what SetVariableA(...) might look like
-----
enum STYLE {FEATURE1 = 0, FEATURE2, FEATURE3}
SetVariableA(...)
{
}
-----
Basically, I am not familiar with the use of enum with bitwise AND, OR, and NOT. Here is a what I would like to accomplish.
- user calls function to setup a feature: function(FEATURE1)
- function determines what feature the user wants
How would you implement some like the above using enum, bitwise AND, OR, and NOT?
Thanks,
Kuphryn
P.S. MFC programmers seem to use the bitwise AND, OR, and NOT
|
|
|
|
|
setVariableA (UINT bitMask)
{
enum STYLE styleIterator;
for (enum STYLE styleIterator=FEATURE1; (styleIterator <= FEATURE3) styleIterator++) {
if (bitMask & styleIterator) {
...
}
}
} /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi Ravi,
Your code doesn't compile, there're several errors. Check your code, compile it, and you will see!
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|