|
If I remember right there are two bytes at the beginning of every Unicode
text file. Just copy the two first bytes of the "correct file" in front of Your file and all will be fine.
|
|
|
|
|
Thank you for your reply Alois, but I want to create the file at runtime.
Regards,
Christos P.
|
|
|
|
|
These two bytes will always be the same once You know them. Just prepend them.
|
|
|
|
|
All unicode text files must begin with the Unicode char 0xFEFF
eperales
|
|
|
|
|
I have a big problem with my MFC PocketPC application!
I have a simple SDI (single document) application, and two command bars on top of my application.
It works very fine, but when I open a dialog (let's say the "Open File..." dialog") and I invoke any one of the SIP components, i.e. the Keyboard and then close the dialog (the Keyboard is visible when I click the "Close" button of my dialog) I will see the view of my application, but the command bars are missing! It look like, that the view resized to the whole area and the command bars are moved outside the screen, so that the command bars are not vissible!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
The following question relates to a programming technique Andrei Alexandrescu presents in Modern C++ Design. Due to the lack of time, I assume you either have read it or understand the concept via experience.
In his book, Alexandrescu shows a generic programming technique he calls "Mapping Integral Constant to Types" in chapter 2, section 2.4. Here is an example.
-----
template <<int a="">>
struct Int2Type
{
enum {type = A};
};
enum TypeA{WIN = 0x0000, LOSS};
template <<typename t,="" int="" u="">>
class XYZ
{
T *Create(Int2Type<<win>> );
T *Create(Int2Type<<loss>> );
};
// Usage
XYZ<<myclass, win="">> zyx;
-----
Again, I assume you understand the concept above.
XYZ<<myclass, win="">> ... compiles as along as you pass in WIN or LOSS. However, here is what I want to do, but have not been able to get Visual C++ to compile without errors.
-----
TypeA myType;
myType = WIN;
XYZ<<myclass, mytype="">> zyx;
-----
I would like to know if there is a solution to the problem above.
The general idea is I want to pass in WIN or LOSS via a variable. The reason I have not implemented WIN and/or LOSS instead of the variable is because in the way I have setup the algorithm. Typing in WIN and LOSS will require switch states and if/else statements.
Thanks,
Kuphryn
|
|
|
|
|
I cannot read your code because you did not set it to show template arguments, but I'm presuming it won't compile in VC because the book in question relies on partial template specialisation, which to date is not offered in any currently available Microsoft compiler. My copy is sitting on the shelf, awaiting Everett.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
It is not entirely clear to me what you're after. Anyway, the lines of code
TypeA myType;
myType = WIN;
XYZ<MyClass, myType> zyx; can't compile because template parameters must be either types (classes, primitive types) or compile-time constants. If you want to hold a variable, pass it on to the object in its constructor. If you specify with a little more detail your problem maybe I can be of any real help
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay. Thanks.
I understand the concept more and why I my design will not work.
I want to create random objects that derive from other objects, but I do not know what.
Object -> A or B or C
A -> D or E or F
B -> G or H or I
C -> J or K or L
Basically, I am implementing an object, but I do not know what classes it and its ancestors are derived from.
Kuphryn
|
|
|
|
|
?? Pardon? I really do not get your point. If you explain it with some pseudocode or something maybe I can try to be of help (the thing seems promising, though ).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I will try a quick example.
-----
- Generate a random number
1 = object 1A
2 = object 2A
...
Given: object xA derives from xB
- Generate a random number
1 = object 1B
2 = object 2B
...
..
..
- Use an object factory to create the object based on the results of the random number.
-----
In general, I am trying to stay away from implement many lines of switch and if/else statements in order to create a single object.
Kuphryn
|
|
|
|
|
Well, you'd have to write some sort of class factory, as you point out. Here's a sketch of what could be done:
class A
{
typedef A* (creator *)();
typedef map<int,creator> creators_map;
static creators_map m;
protected:
static void register(int n,creator c)
{
m[n]=c;
}
public:
A* create(int n)
{
creators_map::iterator it=m.find(n);
if(it==m.end())return 0;
return it->second();
}
};
class A1: public A
{
static A* create(){return new A1;}
public:
static void register()
{
A::register(1,create);
}
...
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
i'm trying to cut some size off a DLL. i removed 3000+ lines of code and saved a total of 4K. if i remove a few hundred lines of code using std::vector, i save 50K.
so, i'm wondering if there's anything else out there that acts like a dynamic array but without the horrible overhead of std::vector? i don't use any of the algorithm stuff on the vectors, no sorting, no foreach, i rarely even use an iterator (usually just .at, .push_back, .size and .clear).
i could write my own, but i don't want to.
no MFC, please.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
Alexandrescu provides something of the sort in his article Generic<Programming>: Typed Buffers (I)[^]. Haven't used it myself, so I don't really know if it can be of help.
Besides, are you exporting (through declspec ) the vector ? This could be the cause of the code bloat you're experiencing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Nope, i don't export them. they are all internal.
thanks for the link.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
you mean you didn't ever write your own Array class?
n/p with the universal balance, though. I got three of them
skulls don't kiss for an explanation - wait for the vacation photos! [sighist]
|
|
|
|
|
i did write my own array class, and i even posted it here. but i'm looking for something slightly different and am a little short on time.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
CAtlArray in VC7 is very good. I used it in my no-STL tests and it saved tons of memory.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
I have developed an application where I want to chk whether a dialog instance is alredy open or not if its already there I dont want to initiate new instance if not then only it should open new dialog instance how can I chk this...please somebody help me.
Thanks
Prateeti
|
|
|
|
|
there are 2 menus in MDI mfc app, one is for main-frame, another one for child-window.
if no child window opened, the menu used is main-fram menu, otherwise is child-window menu.
GetMenu() only gets current menu. I want to get these 2 menus in one function - or at same time (child-window may be opened or not while the function is called), how to do that?
thx.
includeh10
|
|
|
|
|
I don't understand what you want to do ? you want to always see the menu visible when a "child window" is openned ?
|
|
|
|
|
I am trying to set the cleint window background color from a menu selection. I am looking for the member fuctions needed to set the color from my menu
|
|
|
|
|
You will have to do the drawing yourself. The easiest way is probably to store the color in a COLORREF variable in the window which you want to change the background of. Update this variable with the new color and tell the window to redraw itself. Then intercept the WM_ERASEBKGND message and fill the background using this color value. There is a handy function in CDC that does exactly that -> FillSolidRect( ).
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
I think this is simple enough though the solution seems to be eluding me for almost a day now
i have a standard listctrl with checkbox ,say
m_list.SetExtendedStyle(LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT);
what i want is to lock some of the list rows,say row 2
so that the check box value cannot be modified by the user
so i wrote the following in NM_CLICK
{
// TODO: Add your control notification handler code here
NMITEMACTIVATE* pLVCD = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
LVITEM rItem;
int nItem = pLVCD->iItem;
ZeroMemory ( &rItem, sizeof(LVITEM) );
LVITEM rItem;
rItem.mask = LVIF_STATE;
rItem.iItem = nItem;
rItem.stateMask = LVIS_SELECTED|ODS_DISABLED;
m_list.GetItem ( &rItem );
if ( nItem ==2)
{
BOOL bSel=m_list.GetCheck(nItem);
m_list.SetItem(nItem,bSel);
m_list.Update(nItem);
}
*pResult = 0;
}
here if a checkbox is unselected and i click it
the control comes to the above code and bSel is FALSE and eventhough i say to update the list row 2 with that itself ...it doesnt work.
the rows check box gets selected invariable
i tried the same in LV_ITEMCHANGED and a couple of others as well...
but to no avail...
please put me out of my misery
what am i doing wrong??
|
|
|
|