|
Man, I wanna have no resources in my class. I worked kinda hard to create the
icons, pixel by pixel in a matrix...(feels stupid, but hey, you know me...). I wanna load what exists. Me wish not invent no wheel...Man.
Any other ideas?!
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
|
The icon size (used CDC::DrawIcon(...) ) is 32x32.
How can I get the 16x16 icon???
m_hIcon = (<font color=blue>HICON</font>)LoadImage(<font color=blue>NULL</font>, MAKEINTRESOURCE(OIC_INFORMATION), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_SHARED));
CPaintDC dc(...);
dc.DrawIcon(0, 0, m_hIcon); //Draws 32x32 icon!
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
the only solution i've found is to create a 16x16 image list, add the icon to that and then use the imagelist draw functions for the drawing.
somehow, imagelists know how to extract the correct size of icon.
|
|
|
|
|
This is a newbie question but I somehow cannot get this part of my code to work. I have the user input into a character array of unspecified size like this:
char *cArray1 = new char[];<br />
cin >> cArray1;
and then when I try to calculate how many elements is in the array, the sizeof() function always returns 4 for some reason. I'm calculating the number of elements by the following.
size_t iArraySize = sizeof(cArray1)/sizeof(*cArray1);
(I also tried int as the datatype instead of size_t but no luck)
I always get 4 as the return cause sizeof(cArray1) always gives me 4 and 4/1=4.
I think sizeof() cannot be used with dynamically allocated arrays, so is there anyways to do this?
Please give me some advice how so solve this question...
Thanks!
|
|
|
|
|
Use strlen function (don't forget to include <string.h> )!
David Z wrote:
I always get 4 as the return cause sizeof(cArray1) always gives me 4 and 4/1=4
cArray1 is a pointer, not an array. It points at the first element of an array (null-terminated string). It is 4, because in Win32 pointers are 32-bit (4 * 8 bits - that's why you get 4)!
Ñ There is only one MP Ð
|
|
|
|
|
Maciej Pirog wrote:
(don't forget to include )!
Don't forget to include <string.h> of course!
Ñ There is only one MP Ð
|
|
|
|
|
David Z wrote:
sizeof() function always returns 4
because that's the size of a pointer.
-c
For men use, if they have an evil turn, to write it in marble:
and whoso doth us a good turn we write it in dust.
-- Sir Thomas More
|
|
|
|
|
David Z wrote:
I think sizeof() cannot be used with dynamically allocated arrays, so is there anyways to do this?
Use std::vector and its size() member instead.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
The only reason you get 4 (4 bytes) for sizeof (cArray1) is that sizeof actually measures the size of the cArray1, which is a pointer. And as you probably know.... a size of a pointer is 4 bytes (in your compiler anyway...).
char *cArray1 = new char[]; //very bad idea! No array size specified.
instead, use fixed sized buffer: char cArray1[ARR_SIZE];
This one you can measure:
size_t iArraySize = sizeof (cArray1) /sizeof(*cArray1) ;
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
Ok, I really feel dumb now hehe. I was out of code for a while so I totally overlooked that fact about the operator referring to the pointer. Thanks for the help. I just used strlen and it works fine. Thanks for all the help!
|
|
|
|
|
Well...
Your array is actually a pointer, so the function sizeof() will always return
4 because that's the size of a pointer. Getting the number of elements in an
array is a different thing.
Now, I think you should do this some other way. First of all, why would you want to give the user unlimited input length? Just specify a limit and save
yourself a headache.
Second, maybe it could help to know the length of the array before allocating any memory... but, well, what is it you want to do?
Aritosteles
|
|
|
|
|
Hi all,
If I use VS.NET to create a dialog application and say I add a ListCtrl with the designer and set the style to REPORT.
So where is this information stored, does the designer generate code? For example I would look for some code in my project containing LVS_REPORT :
m_myListCtrl.Create(<br />
WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT,<br />
CRect(10,10,400,200), pParentWnd, 1);
but that code does not exist in my project!
Thanks in advance.
Soliant | email
"The whole of science is nothing more than a refinement of everyday thinking." -Albert E.
|
|
|
|
|
There's no generated code. The dialog layout is defined by so-called 'dialog template' stored in program resources. When you invoke dialog box, Win32 API (not MFC) creates the dialog box and populates it with controls.
The code you'll see in MFC app is responsible for creating CWnd-derived objects mapped to their Win32 API counterparts (HWNDs). Look in DoDataExchange for this.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
if u want to just change the style do this:
m_cListCtrl.ModifyStyle(0, LVS_REPORT);
in the constuctor or initdialog();:
Ashok Singh
<west end="" india="">
|
|
|
|
|
Hi
another question
why don't the following code compile?
extern CFile cfile;
void *data;
CFile::Open(m_Pathname1,modeRead);
data = cfile.Read(0,cfile.GetLength());
i get the error:
error C2440: '=' : cannot convert from 'unsigned int' to 'void *'
Conversion from integral type to pointer type requires einterpret_cast, C-style cast or function-style cast
(BTW, what does extern do! Otherwise CFile::Read(etc) also works)
thanks
|
|
|
|
|
extern CFile cfile;
CFile::Open(m_Pathname1,modeRead);
DWORD dwFileLength = cfile.GetLength();
BYTE *data = new BYTE[dwFileLength];
DWORD dwBytesRed = cfile.Read(data,dwFileLength);
Martin
--------------------------------------------
C'mon we all know computers are experimental devices and should only be used for playing games.
Using them for alternative stuff like business, is clearly not using them for what they are intended.
Colin Davies
|
|
|
|
|
tx, this works
what does BYTE *data = new BYTE[dwFileLength] do?
|
|
|
|
|
It allocates memory to hold data from the file. When you will finish using it, then you have to free that memory with:
delete [] data;
I think you have to read little bit more about C++.
Martin
--------------------------------------------
C'mon we all know computers are experimental devices and should only be used for playing games.
Using them for alternative stuff like business, is clearly not using them for what they are intended.
Colin Davies
|
|
|
|
|
|
Jenny2 wrote:
ok hero
Martin
--------------------------------------------
C'mon we all know computers are experimental devices and should only be used for playing games.
Using them for alternative stuff like business, is clearly not using them for what they are intended.
Colin Davies
|
|
|
|
|
I am trying to write two classes that work togeather. One is a color storage class (CSoilColor) and a lookup table class (CColorChart). When I added a member variable to CSoilColor to hold a pointer to a CColorChart object, the compiler choked. Each header file has an include to each other so they should recognize each other, but from the error they apparently do not. Even though the comiler chokes, the development environment recognizes the CColorChart member variable because it allows me access to the CColorChart's members in the CSoilColor's cpp file.
Here are the class definitions:
#include "SoilColor.h"
class CColorChart
{
public:
bool IsValidColor(int nHue, int nValue, int nChroma);
bool GetHue(int nHueID, CString& sHueName);
bool GetRGBcolor(CSoilColor SC, COLORREF* RGBcolor);
void InitChart();
bool GetColorName(int nHue, int nValue, int Chroma, CString& sColorName);
CColorChart();
virtual ~CColorChart();
private:
CString Hue[nMAXHUES];
COLORCHART Chart[nMAXHUES][nMAXVALUES][nMAXCHROMAS];
};
=====================================================
#include "ColorChart.h"
class CSoilColor
{
public:
CSoilColor();
virtual ~CSoilColor();
int GetChroma();
int GetValue();
int GetHue();
COLORREF GetRGBcolor();
bool SetColor(int nHue, int nValue, int nChroma);
private:
CColorChart* m_pColorChart; //ERROR HERE
int m_nHue;
int m_nValue;
int m_nChroma;
};
I think it is probably a simple error, but I am going crazy trying to find it! If anyone has Ideas, please let me know. Thank You.
|
|
|
|
|
Use forward declaration instead of #include:
class CColorChart;
class CSoilColor
{
...
CColorChar *m_pColorChart;
};
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Now that you mention it I did know that at one point.
Thank you very much.
|
|
|
|
|
hi
if i work in VC for a while, i am unable to access the toolbar list that appears whenever you type something like CString p.
is it lack of memory? If i restart my PC it works again...
tx
|
|
|
|