|
I copied the code into 7.1 and it compiled fine.
I don't get those errors even if I don't include afxtempl.h. It almost sounds like you've created your own CMap class within the project. If so, that would be a problem.
Here's what I did to test the code:
1) File -> New -> VC++ Projects -> Win32 -> OK
2) Application Type = Console Application
3) Make sure Add support for MFC is checked
4) Finish
5) Add the #include <afxtempl.h> statement below stdafx.h
6) Add CMap code to _tmain
Compiles fine.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
i followed the same sequence and declared CMap variable.
CMap myMap;
But still it shows the following error
'myMap':UnKnown size
'myMap':Cannot be destroyed
'CMap':no appropriate default constructor available
'CMap' : use of class template requires template argument list
|
|
|
|
|
The map class is templated, so you need to declare the key and value types in the declaration.
CMap<CString, LPCTSTR, int, int> myMap;
-> maps string keys to integer values
CMap<BYTE, BYTE, void*, void*> myMap;
-> maps BYTE keys to void pointer values...
CMap<int, int, CPoint, CPoint> myMap;
-> maps int keys to CPoint values
etc.
More info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_MFC_CMap.asp
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
I forgot to format the angled brackets in my post, causing the #include statement to screw up.
David posted the correct #include
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
but i didn't inclucde #include
But it shows error
|
|
|
|
|
Could someone help me?
First, i use the GetVersionEx function get the OS information.
But for the window server 2003 and 64-bit XP professional,the dwMajorVersion are both 5, and dwMinorVersion are both 2, i found a code snippet at microsoft's website. It is show that :
switch (osvi.dwPlatformId)
{
// Test for the Windows NT product family.
case VER_PLATFORM_WIN32_NT:
// Test for the specific product.
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
printf ("Microsoft Windows Server 2003, ");
//you can view the whole code on
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/detecting_a_product_suite.asp[^]
//here judge the windows server 2003 through the flag VER_PLATFORM_WIN32_NT.
But i found that in 64-bit XP OS, the flag also is VER_PLATFORM_WIN32_NT.
So what should i do to judge the two OS? windows server 2003 and 64-bit XP OS.
>|Gaara|<: boku ha jiben shika aimasen.
|
|
|
|
|
Could someone help me? pls, or give me some tips?
>|Gaara|<: boku ha jiben shika aimasen.
|
|
|
|
|
Hello gurus,
Please be patient with a newbie.
Everywhere I look on the web I see code with these strange vriable types written in capitals like "DWORD" or "HANDLE". Pleople just declare them without having a class of type dword or handle. When I try to use such code, ofcourse the compiler says:
'DWORD' : undeclared identifier
I am trying to use a function called CreateFile which has the attributes:
HANDLE CreateFile(
LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDispostion,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
);
It return type is "HANDLE". What the? Theres no such thing. Is it an int?
MSDN says that "dwDesiredAcess" has to be either 0, GENERIC_READ or GENERIC_WRITE. Is GENERIC_READ a string or what?
When I try to use the the function. ie:
hComm = CreateFile(portname,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
The compiler says:
'GENERIC_READ' : undeclared identifier.
Look, this is a basic question that has porbably been answered elsewhere? But what am I supposed to search for? "variable types written in CAPITALS"?
Pleas help.
|
|
|
|
|
DWORD is just a typedef for unsigned long:
typedef unsigned long DWORD;
HANDLE is just a typedef for void*
typedef void *HANDLE;
handle is a kind of pointer to the windows objects, like bitmaps, brush, etc.
http://www.priyank.in/
|
|
|
|
|
Priyank Bolia wrote:
HANDLE is just a typedef for void*
typedef void *HANDLE;
not always: see WINNT.H
|
|
|
|
|
Hello,
Try:
<br />
#include <windows.h><br />
ans see the magic that can do!
About those types, they are all typedefs by microsoft. All the types that have 'WORD' in their name, are somekind of an int: WORD = 2 bytes unsigned integer, DWORD = 4 bytes unsigned integer and QWORD (Quad WORD) is left as a exercise...
The HANDLE object is a void* pointer to a system object that is managed by windows. The more windows programming you do, the more you see those objects.
Once you learn how to read the MS conventions (try the hongarian notation) some of those names become more easy to read. For example:
LPCTSTR becomes something like: Long Pointer Constant T (unicode, when defined) STRing, where T comes from the macro _T that you use to make unicode strings if you do a unicode build.
I hope that things are more clear now. Good luck on your quest!
I also got the blogging virus..[^]
|
|
|
|
|
1.Project/ADD TO Project/Components And Controls insert SHOCKWAVE FLASH OBJECT Action
********************
The code:
CDialog::OnInitDialog()
{
...
m_ToolBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD
| WS_VISIBLE |CBRS_ALIGN_TOP,CRect(0,5,0,0));
m_ToolBar.LoadToolBar(IDR_TOOLBAR1);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
m_ToolBar.ShowWindow(true);
char cPath[_MAX_DIR];
::GetCurrentDirectory(_MAX_DIR,cPath);
strcat(cPath,"\\ss.swf");
this->m_Flash.SetMovie(cPath);
this->m_Flash.SetParent(&m_ToolBar);
this->m_Flash.MoveWindow(560,0,560,40,true);
this->m_Flash.SetPlaying(true);
....
}
It runing error!Please everybody help me!
|
|
|
|
|
describe the error !
is m_Flash well initialized in the constructor ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
1 Please insert SHOCKWAVE FLASH OBJECT Action in a Dialog.
2 Use ClassWizar-->Member variables add CShockwaveFlash m_Flash.
|
|
|
|
|
i wonder if you understand that we cannot help you if you don't give us the error message in details and if you don't give us the code that's crashing !!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
THKS.
I find the error;P,^!^
|
|
|
|
|
|
1) Create status bar w/panes
2) Get rect of pane that progress ctrl will be placed in using SB_GETRECT
3) Create progress control using status bar as parent, and rect value returned in 2) to set its position.
4) Manipulate progress ctrl as desired.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
To display the ranges of values an unsigned _int64 can have,this is what I wrote:
void myDlg::ShowRanges()
{
unsigned _int64 uValue;
CString uValueStr;
uValue=(unsigned _int64)pow(2,sizeof(unsigned _int64)*8) ;
////////////////////////////////////////////////////////
uValueStr.Format("0 to %I64u",uValue-1);
AfxMessageBox(uValueStr);
}
///////////////////////////////////////////
This is displaying:
0 to 9 223 372 036 854 775 807
instead of the correct answer:
0 to 18 446 744 073 709 551 614
Obviously the answer is truncated by some statment.But where ? In the formatting perhaps?
Thanks for any help.
NB: I added the spaces between the digits to facilitate reading.
|
|
|
|
|
I see two problems here:
1) pow is a floating point function, returning a double, and doubles won't maintain precision to the 20 digits you are expecting.
2) it wouldn't work anyway. You can't represent the range of an integer type as you are doing. For example, think about a byte . That has a sizeof 1, but the range is not 0 to 256, but 0 to 255. Note that 256 will not fit in a byte data type.
The range is actually 0 to 2 to the power of (number of bits) - 1
|
|
|
|
|
If you look in limits.h
#if _INTEGRAL_MAX_BITS >= 64
/* minimum signed 64 bit value */
#define _I64_MIN (-9223372036854775807i64 - 1)
/* maximum signed 64 bit value */
#define _I64_MAX 9223372036854775807i64
/* maximum unsigned 64 bit value */
#define _UI64_MAX 0xffffffffffffffffui64
#endif
Sooooo,
uValueStr.Format("0 to %I64u", _UI64_MAX);
...cmk
Save the whales - collect the whole set
|
|
|
|
|
And that works perfectly.
Thank you so much for your time.
|
|
|
|
|
You could also do :
unsigned _int64 uValue = (unsigned _int64)~0;
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
You are right.
I wrote :
void CMyHexDDlg::ShowRangeOfULONGLONG()
{unsigned _int64 uValue = (unsigned _int64)~0;
CString result;
result.Format("0 to %I64u",uValue);
AfxMessageBox(result);
}
and the output is ( as expected ) :
0 to 18446744073709551615
Very elegant ,and fast solution.
Thank you so much for your time.
|
|
|
|
|
I use this little template class:
template <typename T>
class Limits
{
public:
static T min() { return (T)~0 > 0 ? 0 : (T)1 << (sizeof(T) * 8 - 1); }
static T max() { return (T)~0 > 0 ? (T)~0 : (T)~0 & ~((T)1 << (sizeof(T) * 8 - 1)); }
};
unsigned _int64 ui64Max = Limits<unsigned _int64>::max();
_int64 i64Min = Limits<_int64>::min();
char cMin = Limits<char>::min();
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|