|
I have seen a lot of discussion and examples on sub-classing existing windows controls (i.e. MFC's CEdit) to override or add your own functionality. However, I have found virtually no information on how Window's native controls are created in the first place. WinCtrl fairy maybe? I realize that they are part of the OS and possibly beyond mere mortals.
We have combo boxes, tree contols, list controls, and so on and I have examined creating windows at the API level, that is CreateWindow(...). Is it possible to create an entirely new type of window/control from scratch? Some insight into the "black-box" of windows and controls would be interesting.
Ross White
|
|
|
|
|
Yes. It all starts with a call to RegisterClassEx . Then you define the icons, menus, window message handler, etc. for your totally new 'custom' window type. Typically all this code and the resources required for the menus, icons, brushes, etc. is put into a DLL and then you export a function that registers these custom windows.
For example, you get a many of the 'normal' classes registered when your MFC application calls InitCommonControlsEx .
|
|
|
|
|
|
Yes. Look at the RegisterClassEx function and the WNDCLASSEX structure. This will define the parameters of your new control such as icons, menues, and window procedure. You will have to write your own WndProc and handle any messages you need to draw the control, handle mouse clicks, etc. You most likely would write this code in a dll and export a function to call RegisterClassEx to register your control class before calling CreateWindowEx to create your control.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Thank all for the input. I will have to go back and do some more home work!!
Ross White
|
|
|
|
|
hello!
can anybody tell me how can i create check box in the group box dynamically.
|
|
|
|
|
Find the window handle of your group box.
Do a Create on the checkbox control window and make sure it is inserted in Z-Order AFTER the group box window. That will effectively place the checkbox 'in' the group box. The Z_Order will affect the tab order, which is one of the criteria the group box uses to determine which controls are part of the 'group'. Also, certain controls must have the WS_GROUP style set, all child controls from one with WS_GROUP set untilt the next one with WS_GROUP set are considered a single group.
For example:
Group Box - WS_GROUP
CheckBox - WS_GROUP
CheckBox - NO WS_GROUP
CheckBox - NO WS_GROUP
CheckBox - NO WS_GROUP
Push Button - WS_GROUP
This makes for four checkboxes all part of same group.
|
|
|
|
|
I am trying to set a different font inside a grid tab. The following code is a snippet of what I’m doing. When I run the application it crashes! Has anyone used the function call SetTabFont? And if so can you share some insight on how to properly use this thing. The commented code is what I’m inputting to try and get my desired response.
Thanks for any help, Steve…
void CProcessGrid::OnSetup()
{
CUGCell cell;
CUGTab mTab;
SetNumberSheets(3);
AddTab("Procedure", 0);
AddTab("Parts", 1);
AddTab("Tools", 2);
SetTabWidth(500);
SetCurrentTab (0);
//************ Change Font Size **********[SMB 06/20/05]
//
//CFont *mFont;
//int fontIndex;
//fontIndex = AddFont("Arial", 8, 2);
//mFont = GetFont(fontIndex);
//mTab.SetTabFont(mFont);
//
//*****************************************************
|
|
|
|
|
Is it possible that the mTab object hasn't been created yet (not a window yet)?
|
|
|
|
|
( in VC6 )
I have a DLL from a 3rd party.
there is only one function in the DLL which is declared like this in the simplist documentation :
int __stdcall Function( long,double*, long , long );<code><br />
<br />
in my code I do this : <br />
<br />
<pre>
typedef int (*FunctionProc)(long , double*, long, long );
double* p;
int iRes = FunctionProc( 1, p, 2, 3 );
}</pre><br />
<br />
When I run this, I get a ESP error telling me the calling convention is not good between the DLL function and the function prototype I use.<br />
<br />
I changed the calling conventions of my sample project from __cdecl to __stdcall ( in the project settings ) and it looks like it works, the Function gets called without crashing.<br />
<br />
Is there a way to "transform" the function calling convention ? <br />
<br />
in my real application, I would like not to change the calling convention if possible, I don't really know the implications.<br />
<br />
Thanks.<br />
<br />
Max.<br />
<br />
<br />
<hr><a href="http://www.thesorus.qc.ca">Maximilien Lincourt</a><br />
Your Head A Splode - Strong Bad
|
|
|
|
|
I'd use __cdecl . It has always worked well for me in the past
|
|
|
|
|
No because the caller has been built with a specified calling convention and the stack must be set up accordingly.
|
|
|
|
|
Why not change the typedef
typedef int (__stdcall *FunctionProc)(long, double*, long, long);
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
ok, I think I typo-ed somewhere ...
I do this :
typedef int ( __stdcall * FunctionProc)(long , double*, long, long );
and it seems to "work"...
Thank.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
That is perfectly acceptable
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I have an SDI app with a splitter and two views. The left view is a tree view and I'm trying to make the app come up with the last selection visible/active.
The menus/toolbars are indicating that the view is active but the focus/selection mark in the tree control acts as if it is not the active view. Part of the problem may be that the EnsureVisbile() call doesn't actually make it visible (the selection is hidden under a scroll bar). I don't know if that is what is causing the trouble or if the fact that the view really isn't the active view (in terms of mouse, keyboard) is why they EnsureVisible() isn't working (the chicken/egg thing).
I'm using a timer in the MainFrame and forcing the active view after 300ms using SetActiveView(). Is there something else I should be doing to make the view act as if I just clicked on the item? Any idea why the EnsureVisible() isn't placing the selected item within sight?
Thanks.
|
|
|
|
|
Can someone please tell me what i am doing wrong here. I can load the XML file fine but when i select the node that i want and try to retrieve the text, i get nothing back.
std::string value;
HRESULT hr;
MSXML2::IXMLDOMDocumentPtr pDocument;
MSXML2::IXMLDOMNodePtr ptagNode;
_bstr_t mybstrtagResponseKey = "//Response//ResponseKey";
_bstr_t mybstrtagResponseText = "//Response//ResponseText";
_bstr_t myxmlfile = "C:\\sample.xml";
// Create XMLDOMDocument
hr = CoInitialize(NULL);
hr = pDocument.CreateInstance("Msxml2.DOMDocument.4.0");
if (FAILED(hr))
{
}
try
{
// Load xml file.
if (pDocument->load(myxmlfile)!= VARIANT_TRUE)
{
}
else
{
ptagNode = pDocument->selectSingleNode(mybstrtagResponseKey);
//if text exists, get it...
while (ptagNode)
{
value = ptagNode->text;
}
}
}
|
|
|
|
|
It doesn't appear that you're setting the root:
You're not setting the root:
MSXML2::IXMLDOMDocumentPtr plDomDocument = NULL;
MSXML2::IXMLDOMElementPtr pDocRoot;
HRESULT hr = plDomDocument.CreateInstance(MSXML2::CLSID_DOMDocument);
if (SUCCEEDED(hr))
{
BSTR xml = _com_util::ConvertStringToBSTR(response);
variant_t vResult = plDomDocument->loadXML(xml);
if (((bool)vResult) == TRUE)
{
MSXML2::IXMLDOMElementPtr pDocRoot = plDomDocument->documentElement;
CComPtr<MSXML2::IXMLDOMNode> pDisp = pDocRoot->selectSingleNode(_T("Disposition"));
if (pDisp)
...
|
|
|
|
|
By the way, in my code I'm loading the DOM object from memory (via loadXml) while you're doing it from disk (via load). However, the main issue is that you have to set the root and call its selectXXX functions to retrieve the desired elements.
|
|
|
|
|
I learn something new everyday. This is awsesome. I must say, Tom, you really know your XML. I appreciate your help.
I have another question though...
After i retrieve the node value, it will be a blob of data. I have to search this blob and pick out certain pieces of data. I am currently looking to use std::string. Is there a cooler way to search text using XML instead of string? Or is string sufficient for this case?
|
|
|
|
|
Hi!
I'm creating a small program that reads from a text file, using ifstream.
I'm wondering how I can tell the stream to start reading the file from the beginning?
Is this possible or do I have to close the file and reopen it?
This is what I'm doing:
ifstream file(filename);
if(!file.is_open())
{
// Error message.
}
while(!file.eof())
{
file.getline(buf, 200);
// after comes more code that is not relevant here.
}
When I do this getline starts reading line by line.
So how can I tell it to start from the beginning?
Thanks!
|
|
|
|
|
but why do you need to read from beginning again
I love Programming
|
|
|
|
|
Well I need to get some more data from the file.
Is it possible or not?
|
|
|
|
|
You can use the seekg method for that. Something like
ifstream input("C:\\Test.txt");
int txt = 0;
input >> txt;
cout << txt;
input.seekg(0, ios::beg);
input >> txt;
cout << txt;
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
i made a linked list of nodes...! but i need to save my list of nodes on hard disk...
and i need to load this list when i open my program...
(it is a phonebook program in console application)
|
|
|
|