|
Hi there.
I would be greatful if someone have abit of sample code for me. I'm sure this isn't a difficult problem to someone that uses ADO/C++ on a regular basis.
I want to put a Checkbox column into a C++'s CDataGrid object (dialog based program). Do bear in mind, it's VC 6.0 and not .NET I'm using here.
Thanks..
w
|
|
|
|
|
Deleting intermediate files and output files for project 'tmplts_12052005 - Win32 Debug'.
--------------------Configuration: tmplts_12052005 - Win32 Debug--------------------
Compiling...
test.c
c:\tmplts_12052005\vector.h(4) : error C2143: syntax error : missing '{' before '<'
c:\tmplts_12052005\vector.h(4) : error C2059: syntax error : '<'
c:\tmplts_12052005\test.c(5) : error C2146: syntax error : missing ')' before identifier 'size'
c:\tmplts_12052005\test.c(5) : error C2061: syntax error : identifier 'size'
c:\tmplts_12052005\test.c(5) : error C2059: syntax error : ';'
c:\tmplts_12052005\test.c(5) : error C2059: syntax error : ')'
c:\tmplts_12052005\test.c(5) : error C2449: found '{' at file scope (missing function header?)
c:\tmplts_12052005\test.c(31) : error C2001: newline in constant
c:\tmplts_12052005\test.c(34) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
tmplts_12052005.exe - 9 error(s), 0 warning(s)
-----------------------------------------------------------------------------------
/* File Vector.h */
//typedef int T;
template <class t="">
class Vector {
public:
struct RANGE_ERROR {};
Vector (size_t len = 100): size_ (len) {
if (this->size_ <= 0)
throw Vector<t>::RANGE_ERROR();
else this->buf_ = new T[this->size_];
}
~Vector (void) { delete [] this->buf_; }
size_t size (void) const { return this->size_; }
T &operator[] (size_t i) {
if (this->in_range (i))
return this->buf_[i];
else throw Vector<t>::RANGE_ERROR ();
}
protected:
T &elem (size_t i) { return this->buf_[i]; }
private:
size_t size;
T *buf_;
bool in_range (size_t i) {
return i >= 0 && i < this->size_;
}
};
==================================================================
ssnn
|
|
|
|
|
Does anyone know how to get/retrieve selected text from IE or Word?
Any information, whatsoever, would be most appreciated.
Be well.
|
|
|
|
|
|
Thank you very very much and (btw) your article is excellent. Don't know how I missed it. Gets my 5.
Thanks again and be well.
|
|
|
|
|
Hi,
I have an MFC tab control which holds a couple of dialogs. On the first page there is a dialog which has a CListCtrl. I would like to implement
Ctrl + Tab => next page
Shift + Ctrl + Tab => prev page.
I thought this was simple - I would just override a WM_CHAR or WM_KEYDOWN or something similar. But the MFC handlers for these messages do not react to holding down/releasing Tab. They also don't give info, whether a combination of control keys like shift and ctrl are pressed together with tab.
Will I have to override PreTranslateMessage and set/unset a flag for the shift resp control keys when they are pressed/released? Or is there a more elegant solution?
Or is that kind of behavior already part of the tab control's standard implementation, and I just don't realize?
Thanks in advance
regards Werner
|
|
|
|
|
I'm having real problems getting titles onto the tabs of a multi page Property Sheet.
I'm creating several pages dynamically in the Prop Sheet's constructor which are the names of all the ini files in a folder, as below:
However, the titles do not appear on the tabs and the only way I can get them on is to hard code them, instead of the line which assigns the title e.g pPage->m_psp.pszTitle = "Page Title";
Iv'e tried casting the strFound variable to (LPCTSTR) but stil no joy although this shouldn't be necessary.
Kind of defeats the idea of doing stuff dynamically!
Any help would be really appreciated - I've been round and round in circles on this!
Many thanks.
[I]if( GetCurrentDirectory( 256, (LPSTR) szCurrentDir ) != 0)
{
strFile.Format("%s%s", szCurrentDir, "\\system\\*.ini");
CFileFind finder;
BOOL bResult = finder.FindFile( strFile, 0 );
// get any ini file names...
while( bResult )
{
bResult = finder.FindNextFile();
// we don't want folders...
if( finder.IsDots( ) )
continue;
// get the file name...
CString strFound(finder.GetFileName());
// remove the extension...
strFound.Delete( strFound.GetLength()-4, 4);
// create a new property page...
CDiaryPage* pPage = new CDiaryPage( strFound );
// set its attributes...
pPage->m_psp.dwFlags = PSP_USECALLBACK | PSP_USETITLE | PSP_HASHELP;
// and give it its title...
[U]pPage->m_psp.pszTitle = strFound;[/U]
// then add it to the sheet...
AddPage( pPage );
}
finder.Close();
}[/I]
code dope.
Life's like a sh*t sandwich - the more bread you got, the less sh*t you gotta eat!
|
|
|
|
|
code dope wrote: // remove the extension...
strFound.Delete( strFound.GetLength()-4, 4);
What about PathRemoveExtension() ?
I'm not sure about the actual problem you're having, however. What happens if you use CPropertyPage::Construct() ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
code dope wrote: I'm having real problems getting titles onto the tabs of a multi page Property Sheet
From the property sheet class use
TCITEM TCItem = {0};
TCItem.mask = TCIF_TEXT;
TCItem.pszText = "Tab Text";
GetTabControl()->SetItem(PageIndex, &TCItem);
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Hello -
This may be a very dumb question, but I've struggled with it a long time. I have two text boxes and I'm trying to control their visibility and enabled/disabled state, but no matter what I do I keep getting this or something like it with different commands:
VestExample error C2228: left of '.ShowWindow' must have class/struct/union type
Here is some of the code:
In header file (Dialogue Data):
int m_partnum; // text box
int m_degrees; // text box
In .cpp file:
DDX_Text(pDX, IDC_PARTNUM, m_partnum);
DDX_Text(pDX, IDC_DEGREES, m_degrees);
Lines causing error:
m_partnum.ShowWindow(SW_HIDE);
m_partnum.ShowWindow(SW_SHOW);
m_degrees.EnableWindow(true);
I have various buttons that respond just fine to these commands (defined in class wizard) and the text boxes are defined in the class wizard too. Thanks in advance for any help.
-- modified at 16:02 Monday 5th December, 2005
|
|
|
|
|
show us the code for that particular line of code ( with as much contextual info as possible .
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks for your reply. Here is the code:
In header file (Dialogue Data):
int m_partnum; // text box
int m_degrees; // text box
In .cpp file:
DDX_Text(pDX, IDC_PARTNUM, m_partnum);
DDX_Text(pDX, IDC_DEGREES, m_degrees);
Lines causing error:
m_partnum.ShowWindow(SW_HIDE);
m_partnum.ShowWindow(SW_SHOW);
m_degrees.EnableWindow(true);
Thanks again for any help!
|
|
|
|
|
int m_partnum;
int m_degrees;
but those are not Control member variables, they are int ; make certain that you define variables for your controls, or do something like :
CWnd* pWnd = GetDlgItem( ID_OF_CONTROL );
pWnd->ShowWindow(SW_HIDE);
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
damn !
maximilien already answered, but i'd really like to say this.
error C2228: left of '.ShowWindow' must have class/struct/union type
isn't the compiler message explicit enough ?
ok, you're a "newbie". let's start back.
left of '.ShowWindow' : m_partnum.ShowWindow(SW_HIDE);
i hope so you see that the compiler talks about m_partnum.
but you declared it as an integer (int m_partnum; ).
int is NEITHER (as the message tells) a class nor a struct nor a union but a native type of the language (here C++)
so you cannot apply the '.' operator to an int variable in which no such operator is defined.
moreover, what you what to do is applying this on a control (showing or hiding a particuliar control). you must have a variable or the type (or subtype) in which the ShowWindow() member function is defined (here CWnd).
almost all the controls inherits from CWnd, so a CEdit, a CButton, a CComboBox will also have their ShowWindow() Method...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20]
|
|
|
|
|
newbie5345 wrote: VestExample error C2228: left of '.ShowWindow' must have class/struct/union type
What does the line in question look like? In the context of what type of object is ShowWindow() being called?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Thanks for your reply. Here is the code:
In header file (Dialogue Data):
int m_partnum; // text box
int m_degrees; // text box
In .cpp file:
DDX_Text(pDX, IDC_PARTNUM, m_partnum);
DDX_Text(pDX, IDC_DEGREES, m_degrees);
Lines causing error:
m_partnum.ShowWindow(SW_HIDE);
m_partnum.ShowWindow(SW_SHOW);
m_degrees.EnableWindow(true);
Thanks again for any help!
|
|
|
|
|
newbie5345 wrote: int m_partnum; // text box
int m_degrees; // text box
Should be:
CEdit m_partnum;
CEdit m_degrees; newbie5345 wrote: DDX_Text(pDX, IDC_PARTNUM, m_partnum);
DDX_Text(pDX, IDC_DEGREES, m_degrees);
Should be:
DDX_Control(pDX, IDC_PARTNUM, m_partnum);
DDX_Control(pDX, IDC_DEGREES, m_degrees);
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
|
Hello,
I'm trying to create an automated build process for a Visual Studio 6 project. When I call nmake (C:\Program Files\Microsoft Visual Studio\VC98\Bin\NMAKE.EXE) and specify my makefile (exported from VS6) Visual Studio 2003 is launched and I'm asked to "convert the project".
What's the story? Why is VS2003 butting in? Why isn't nmake just making the taget file?
I'm new to the automated build stuff. Any help would be greatly appreciated.
Thanks!
-Ian
-- modified at 14:35 Monday 5th December, 2005
|
|
|
|
|
I know just enough programming to get in trouble, I am starting to get into programming motion controllers that use C++, does anyone know of any good self-training books,
Thanks
|
|
|
|
|
Hello,
There are a lot of books that you can learn from, but the book that is right for you depends on your background. Since you say that you already know a little bit of programming, I can recommand "The C++ programming Language" by Bjarne Stroustrup. He's the creator of C++ and his book covers everything you need to know for getting a solid understanding of the language.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello all and thanks in advance. I have a multiple dialog MFC app. On several of these dialogs there are many (20+) settings that could be changed. I am implementing an Apply button than becomes enabled when any of the controls are changed. Currently I'm handling a change event for every item, but I was wondering if there is a general message that I could handle on the dialog level that would be sent by all of the controls if a change occured. Then I could handle one event instead of many.
Thanks!
Jim
|
|
|
|
|
How about ON_NOTIFY_RANGE() ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
yes I think this will work! Thanks Dave. I think I'll have to set a few message maps up because there are three different types of controls (dropdown, textbox and spin). I'll just point them all to the same function.
And I might have to rearrange the IDs in the resource file so same-type controls are continguous. But beyond that I think this work.
I'll post a followup.
Thanks, Jim
|
|
|
|