|
I'm looking for some exercises regarding Visual C++. If you happen to know some sites or have some, please reply to my post. Thanks!
|
|
|
|
|
I'm looking for some exercises
Exercise means Bench Press, Pullups, Pushups kind of?
If you happen to know some sites or have some, please reply to my post.
This is the best.
-- modified at 22:41 Monday 5th December, 2005
|
|
|
|
|
If u mean u want to learn VC++
just this site ur in is great
1>Codeproject
2>MSDN nothing can help u better then msdn.
ok
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
How do I generate random numbers between 0 and 99?
|
|
|
|
|
|
|
41 (you thought i'd say 42, so 41 is random).
... want another - 53.
Feel free to ask me whenever you want another one.
... or you can do what the other Chris said - use srand()/rand().
Or, you can do what most encryption engines do:
- accumulate a blob of random input data:
- current time
- current mouse position
- pixel color at mouse position
- process id, thread id
- mac address
- ...
- create a hash of the blob e.g. using SHA
SHA1 is 20 bytes long so you could use the resulting hash to get 20 random numbers by taking hash[i] % 100, where 0 < i < 20.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
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
|
|
|
|