|
firstly a good unicode editor helps:
http://www.unipad.org/main/[^]
secondly the STL way is to convert to wide strings and streams
and (essential) use locales to 'imbue' them with the
ability to handle the unicode conversion that you desire
//include all the culture specific information you need
#include <locale>
//reveal the current locale
locale default_locale = wcout.getloc();<br />
cout << default_locale.name();
which if nothing has been imbued is C for classic
//create a new locale
locale french_locale("french");
//reveal its name
cout << french_locale.name();
//French_France.1253 in windows
//the names are non standard
//but the locales construct happily with intuitive language name or abbreviation
//see: http://www.microsoft.com/globaldev/nlsweb/default.asp[^]
//set a new locale
locale old_locale = wcout.imbue(french_locale);
use the widen and narrow methods to convert
and you should be away
a good code project article is here...
http://www.codeproject.com/vcpp/stl/upgradingstlappstounicode.asp?df=100&forumid=16224&exp=0&select=557556[^]
|
|
|
|
|
Hi all,
How can I use C++ object in C code?
Let's say an object is implemented by others in C++, but I want to use this object in my C code.
Is this possible?
Is there any trick I can use?
Thanks in advance!
--Tosh
|
|
|
|
|
I doubt this is possible....
even if you know the memory schema of an allocated object, you won't be able to access the members (for instance by dereferenciate a pointer to the address needed) if they were defined private or protected...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You can do the following, create a .cpp file and put a extern "C" function into it. This function can access your CPP object and can also be called from your C file.
foo.cpp
--------
<br />
extern "C" int call_to_obj ()<br />
{<br />
return myObject.SomeMethod ();<br />
}<br />
I hope that helps.
-- modified at 6:12 Tuesday 17th January, 2006
|
|
|
|
|
i am a novice in game programming and i want to ask how
a program can read two keys simultaneously.
|
|
|
|
|
Direct Input, part of DirectX.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Train free @Microsoft
Got to this link and register free for
training your self for VS2005
https://www.microsoftelearning.com/visualstudio2005/
or
http://www.financialexpress.com/latest_full_story.php?content_id=107645
Microsoft dont give anything free except training
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hello...
I am having trouble setting the initial size of my SDI application. I thought that I would be able to override the PreCreateWindow() function in my MainFrame and reset the values of the CREATESTRUCT like this:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.cx = 1000;
cs.cy = 730;
if(!CFrameWnd::PreCreateWindow(cs))
return false;
return TRUE;
}
However, this does not work. I also tried the MoveWindow() function and SetWindowPos() function in the OnSize of CMainFrame. That looks like this..
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cy, cy);
if(!m_ResizeFlag)
{
MoveWindow(300, 300, 1000, 730);
m_ResizeFlag = true;
}
}
This did not work, either..
Any help would be MUCH appreciated!
Thanks in advance!
~SheriMarie
|
|
|
|
|
I add #include <windows.h> to stdafx.h file in windows form application and it dosent want to compile the project issuing this:
error C2039: 'GetObjectW' : is not a member of 'System::Resources::ResourceManager'
for this piece of code:
this->Icon = (__try_cast<system::drawing::icon *="">(resources->GetObject(S"$this.Icon")));
I just assigned new icon to my application and this code was added atomatically, but without #include <windows.h> it is compiled normally?
9ine
|
|
|
|
|
undefine GetObject and define a GetObject_T macro for calling the GetObjectA and GetObjectW API.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
would you please indicate where should I undefine this macro and how to define another GetObject_T
9ine
|
|
|
|
|
another error with this code?
MessageBox::Show(this, S"err");
error C2653: 'MessageBoxW' : is not a class or namespace name
9ine
|
|
|
|
|
#undef MessageBox
#undef GetObject
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
Hi Folks,
I got a Wrapper Dll around a native C++ static library. In .NET 1.1 this
worked fine. When moving to .NET 2.0 I get a couple of unresolved externals /
linker errors:
Error 16 error LNK2028: unresolved token (0A000007) "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public:
virtual __thiscall std::logic_error::~logic_error(void)"
(??1logic_error@std@@$$FUAE@XZ) Parameter.obj
Error 17 error LNK2028: unresolved token (0A000007) "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public:
__thiscall std::bad_alloc::bad_alloc(char const *)"
(??0bad_alloc@std@@$$FQAE@PBD@Z) Imagic.obj
Error 18 error LNK2028: unresolved token (0A000008) "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public:
virtual __thiscall std::logic_error::~logic_error(void)"
(??1logic_error@std@@$$FUAE@XZ) Align2D.obj
Error 19 error LNK2028: unresolved token (0A000347) "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) referenced in function "public: virtual void
* __thiscall std::logic_error::`vector deleting destructor'(unsigned int)"
(??_Elogic_error@std@@$$FUAEPAXI@Z) Parameter.obj
Error 20 error LNK2028: unresolved token (0A0003D3) "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) referenced in function "public: virtual void
* __thiscall std::bad_alloc::`vector deleting destructor'(unsigned int)"
(??_Ebad_alloc@std@@$$FUAEPAXI@Z) Imagic.obj
Error 21 error LNK2028: unresolved token (0A000358) "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) referenced in function "public: virtual void
* __thiscall std::logic_error::`vector deleting destructor'(unsigned int)"
(??_Elogic_error@std@@$$FUAEPAXI@Z) Align2D.obj
Error 22 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ) Align2D.obj
Error 23 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ) AssemblyInfo.obj
Error 24 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ) Imagic.obj
Error 25 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ"
(?.cctor@@$$FYMXXZ) Parameter.obj
Error 26 error LNK2019: unresolved external symbol "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in function "public:
virtual __thiscall std::logic_error::~logic_error(void)"
(??1logic_error@std@@$$FUAE@XZ) Align2D.obj
Error 27 error LNK2001: unresolved external symbol "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) Imagic.obj
Error 28 error LNK2001: unresolved external symbol "extern "C" void
__clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)"
(?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) Parameter.obj
Error 29 error LNK2019: unresolved external symbol "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) referenced in function "public: virtual void
* __thiscall std::logic_error::`vector deleting destructor'(unsigned int)"
(??_Elogic_error@std@@$$FUAEPAXI@Z) Align2D.obj
Error 30 error LNK2001: unresolved external symbol "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) Imagic.obj
Error 31 error LNK2001: unresolved external symbol "void __clrcall `eh
vector destructor iterator'(void *,unsigned int,int,void (__clrcall*)(void
*))" (??_M@$$FYMXPAXIHP6MX0@Z@Z) Parameter.obj
Error 32 fatal error LNK1120: 9 unresolved externals Debug\empDll.dll
In my .NET 1.1 Project I had to make the following Linker Settings to build
the DLL:
1.) Additional Dependencies: mscoree.lib msvcrt.lib (or msvcrtd.lib for
debug version) mystaticlib.lib
2.) Ignore Specific Library: nochkclr.obj
3.) Force Symbol Reference: __DllMainCRTStartup@12
In my Wrapper Classes I had to add the following:
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
This does not work any longer with the new Visual Studio and the new .NET
Framework.
The only article that I was able to find on this subject:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/TransGuide.asp
Doesn´t mention Linker settings at all.
Could anybody please help me or tell me where to go for further reading?
Thanks in Advance for your efforts.
Chucker
|
|
|
|
|
Building Q3.obj.
Building WeekOne.exe.
POLINK: error: Symbol '_main' is multiply defined.
*** Error code: 1 ***
Done.
Im doing this simple program and i got this error after executing. Below is the code. Please help.
_____________________________________________________________________________
#include <stdio.h>
int main ( ) {
int gross_sales;
int earnings;
int counter;
earnings = 200;
counter = 0;
while ( counter !=7 ){
printf("\nEnter Gross Sales:");
scanf("%d", &gross_sales );
counter = counter + 1;
}
earnings = 200 + 0.9*gross_sales;
printf("\nTotal earnings for last week is %d:\n", earnings);
return 0;
}
|
|
|
|
|
did you created an empty project or used the wizard ?
if you've choosen the later, the wizard may have already defined the main() function somewhere in the code - as the error tells us.
one question though, what was the file #include d ? stdio.h ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi, I have the following code
Stream *stream = File::Open(fileCFDPath, FileMode::Open, FileAccess::Read);
this->XmlStream = stream;
XPathDocument *doc = new XPathDocument(stream);
this->XmlStream->Position = 0;
The code breaks since XPathDocument automatically closes the stream, how could I clone the stream in order that I have a copy of the stream and I dont have to go and bring from disk the info again??
Thanks in advance
Isaac B
|
|
|
|
|
to clone an object is a java (or .NET) naming. in C++, where variables are not necessarily handled by reference, everything is done in the constructor (if it is well written of course )
so, something like the following should work :
Stream* s1 = ;
Stream s2 = new Stream(*s1);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I need help with my orderedlist.cc. In the end we are to produce a sorted word dictionary which will reads words in and output them in sorted form. This is just two of the files. I also have KeyValue.h, KeyValue.cc staticHTable.h, staticHTable.cc.
This is the provided h file given:
<br />
include <string><br />
#include "KeyValue.h"<br />
using namespace std;<br />
<br />
class OrderedList<br />
{<br />
public:<br />
OrderedList();
~OrderedList();
<br />
<br />
void insert( string word, string definition);<br />
<br />
<br />
const string inspect( string w ) const;<br />
<br />
bool isIn( string w ) const;<br />
<br />
bool isEmpty() const;<br />
<br />
void printEntry() const;<br />
<br />
public:<br />
KeyValue* head;<br />
};<br />
the cc file of it of which i have done some but struggling to do and understand the next bits!
<br />
#include <iostream><br />
#include <stddef.h><br />
#include "OrderedList.h"<br />
#include <string> <br />
<br />
using namespace std;<br />
<br />
KeyValue::KeyValue()<br />
{<br />
word = "\0";<br />
definition = "\0";<br />
next = NULL;<br />
}<br />
<br />
OrderedList::OrderedList()<br />
<br />
{<br />
head = NULL;<br />
}<br />
<br />
OrderedList::~OrderedList()<br />
{<br />
KeyValue* Current;<br />
KeyValue* it;<br />
<br />
it = head;<br />
while (it != NULL);<br />
<br />
{<br />
Current = it;<br />
it = it->next;<br />
delete Current;<br />
}<br />
}<br />
<br />
bool OrderedList::isEmpty() const<br />
{<br />
return head == NULL;<br />
}<br />
<br />
<br />
<br />
void OrderedList::insertBefore(const int newval, const int val)<br />
{<br />
KeyValue* p = new KeyValue;<br />
KeyValue* iterator = NULL; <br />
KeyValue* previous = NULL;<br />
<br />
p->word = newval;<br />
p->next = NULL;<br />
if (isEmpty())<br />
{<br />
cout << "List is empty\n";<br />
}<br />
else<br />
{<br />
for (iterator = head; iterator != NULL; iterator = iterator->next)<br />
{<br />
if (iterator->word == val) <br />
{<br />
if (iterator == head)<br />
{ <br />
head = p;<br />
}<br />
else<br />
{<br />
previous->next = p;<br />
}<br />
p->next = iterator;<br />
break;<br />
}<br />
else <br />
{<br />
previous = iterator;<br />
}<br />
}<br />
}<br />
}<br />
<br />
void OrderedList::printEntry() const<br />
{<br />
if (isEmpty())<br />
{<br />
cout << "List empty" << endl;<br />
}<br />
else
{<br />
KeyValue* p = NULL;<br />
for (p=head; p!=NULL; p=p->next)<br />
{<br />
cout << p->word << endl; <br />
}<br />
}<br />
}<br />
i need help in doing the const string inspect( string w ) const; function and bool isIn( string w ) const becasue i really dont know how to do this to matter how much i have a go at it. Also what would be helpful if someone could also check that i have done everything right in the cc coding becasue i have got some errors for it! Also do i need to include a main program for this. I can also provide the KeyValue.h and KeyValue. files if needed.
Thanks (Hopefully you will be able to help me on this cos i have been finding this very very hard.
|
|
|
|
|
Hi! I am a bit stumped..
I am a fairly new MFC programmer, and I am creating a form-based application with mulitiple tabs. I am using the CTabCtrl class to create the tabs. Those work great, and I can even switch back and forth between tab views when I click on the tabs, but when I resize the main window the tabs have a static size. I would love it if the tabs also resized. Each of my tabs are dialogs.. I am not sure if that matters.
I did create an ON_WM_SIZE() message handler, and when the main window is resized, the breakpoint stops there. So I figure I need to add code in this message handler somewhere:
<pre)
void cresizeview::onsize(uint="" ntype,="" int="" cx,="" cy)
{
="" if(ntype="" !="SIZE_MINIMIZED" &&="" (cx=""> 0) && (cy > 0))
{
// Resize tabs????
}
CFormView::OnSize(nType, cx, cy);
}
I know I also need to somehow obtain a pointer to my tabs which are within the view. Not sure how to do that. One of the many reasons I am so confused.. any help would be greatly appreciated!!
~Sheri
|
|
|
|
|
|
Hi,
How do I overload operator[] such that when i have the following statement in my program:-
a[10][20][3]; //any number of dimensions
The requirement is :
1) i should be able to accept the values in the subscript operators.
2) With those values, i should be able to allocate memory dynamically in my operator[] function.
3) the function should be able to accept variable number of arguments(here, a[3][2][3][2]; has four arguments....namely a,3,2,3,2).
please help me.
PK
|
|
|
|
|
an alternative to such a behavior is to overload the operator () instead, but i conceed, you will have a fixed number of dimension...
i don't think overloading the operator [] is possible for such a thing, because look :
if you have myType t[10];
[] will work on a myType array (every thing fine so...)
but with myTpe t[10][20];
the second [] will work on a myType[10] array... now, everything goes hard because you would have to overload as many versions of the [] as you want for the first dimension !!!
imagine myType[10][20][30];
the 3rd [] works on a myType[10][20] array !!!!!!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: i don't think overloading the operator [] is possible for such a thing,
Why? This will work for infinite dimensions.
class A
{
public:
A operator [](int index)
{
A a;
return a;
}
};
Of course, it'll be tough to code the body of the function, as you won't know which dimension you are in.
Oh, in myType[10][20], the second dimension operates on whatever was returned by the first [], so it's not really overloading for myType[10].
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
-- modified at 4:35 Saturday 5th November, 2005
|
|
|
|
|
For a 2-D situation the easiest thing to do is something like this:
<code>
Array of arrays of ints
typedef vector<vector<int> > CMultiIntArray;
void TraceDynamicArray(const unsigned int rows, const unsigned int columns)
{
CMultiIntArray aTest;
// Allocate number of rows
aTest.resize( rows );
// For each row
for (int row = 0; row < aTest.size(); row++)
{
// Allocate number of columns
aTest[row].resize( columns );
// For each column
for (int column = 0; column < aTest[row].size(); column++)
{
// Assign a value
aTest [row] [column] = 10 * row + column;
// Trace it
cout << aTest [row] [column] << "\t";
}
cout << "\n";
}
}
// Example usage: Standard C++ Library version
int main(int argc, char* argv[])
{
TraceDynamicArray(3,5);
return 0;
}
// For rows = 3, columns = 5, produces output...
// 0 1 2 3 4
// 10 11 12 13 14
// 20 21 22 23 24
</code>
Then you can do something similar for higher dimensions. But you have to define the dimensions upfront.
Kevin
|
|
|
|