|
I have a project which was started as ANSI, and the project can't be converted to unicode for the foreseeable future. However, I have to display some unicode filenames in a list box by calling the unicode versions of the Win32 functions. But I have a problem.
LPCWSTR strFile = L"Some chinese or arabic unicode text, like that - يتشخيتختصضخيتضختصت.doc";
MessageBoxW(0, strFile, 0, 0);
SendDlgItemMessageW(GetSafeHwnd(), IDC_LISTBOX_FILES, LB_ADDSTRING, 0, (LPARAM) text);
The code above will show the message box with the correct unicode text, but it will display "????????.doc" in the list box. I tried changing the font of the list box but it didn't fix it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
What is the text here ?
virtual void BeHappy() = 0;
|
|
|
|
|
Hi friends,
I need immediatly simple treeview in cview full sample code, plz help me.
Thanks and Regards,
D.Manivelan,
|
|
|
|
|
Create a new project (either MDI or SDI) with the wizard and at one of the last step of the wizard, you can select what type of view you want to use as the default view of your application.
or, if you already have an application with a default CView class, you could create a CTreeCtrl object in the view and use it.
for example :
class YourView : public CView
{
CTreeCtrl m_YouTree;
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct );
afx_msg void OnSize(UINT nType, int cx, int cy);
};
and
int YourView::OnCreate(LPCREATESTRUCT lpCreateStruct )
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rect;
GetClientRect(rect);
m_Tree.Create(WS_CHILD|WS_VISIBLE, rect, this, 1234);
m_Tree.InsertItem(_T("root"), TVI_ROOT);
return 0;
}
void YourView::OnSize(UINT nType, int cx, int cy)
{
if ( m_Tree.GetSafeHwnd() )
{
CRect rect;
GetClientRect(rect);
m_Tree.MoveWindow(rect);
}
}
Max.
Watched code never compiles.
|
|
|
|
|
|
Hi, I made an app in MFC VS2008 which works ok, but there are some PC's where my app just wont work (you allready know this story right..) so I decide it would be for the best to staticly link MFC. This produced some errors while compiling:
1>mysys.lib(my_messnc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp____p__iob referenced in function __db_push_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp____p__iob
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__fprintf referenced in function __db_enter_
1>libmysql.lib(net.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(safemalloc.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>mysys.lib(my_init.obj) : error LNK2001: unresolved external symbol __imp__fprintf
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__vfprintf referenced in function __db_doprnt_
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__getpid referenced in function _DoPrefix
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp__getpid
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__perror referenced in function _DBUGOpenFile
1>libmysql.lib(dbug.obj) : error LNK2019: unresolved external symbol __imp__freopen referenced in function _dbug_flush
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p__pctype referenced in function _my_error
1>mysys.lib(my_error.obj) : error LNK2019: unresolved external symbol __imp____p___mb_cur_max referenced in function _my_error
1>strings.lib(Int2str.obj) : error LNK2019: unresolved external symbol __imp__ldiv referenced in function _int2str
1>OLDNAMES.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp___getpid if anyone can Help please do so. I've been googling and still couldn't find the right way. Thanks in advance, and sorry for my bad language!
|
|
|
|
|
I guess the libraries you're using link dynamically with the runtime.
Why don't you deploy the required DLL's instead of linking the project statically?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
First let me thank you for replaying.
I have following requirements I need to keep. I need to distribute my exe to multiple machines with no knowledge about OS installed. I've tried on several local computers and where app didn't work I've get different error messages. So by static linking MFC I hope I'll be able to get it to work!
|
|
|
|
|
However, if my previous guess was correct, you have to either get new (statically linked with the runtime) binaries of the libraries you use or compile yourself such libraries.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
My app works with mysql db and only lib's I'm linking are: libmysql.lib, mysys.lib and strings.lib. And trough my code I have
#pragma comment(lib, "Netapi32.lib")
#pragma comment(lib, "mpr.lib")
#pragma comment(lib, "shlwapi.lib") This is an simple sdi app created with vs2008. Sure I have some CMFC controls (like toolbars and so) which are from feature pack. I didn't try to install re-distributable file on target machines.
modified on Tuesday, March 23, 2010 8:28 AM added additional libs from my code
|
|
|
|
|
to link staticly is one solution. For that you need the static libs of mysys.lib etc.
or you build a setup which will include the dlls which you will need. Test it on virtual machines.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
With Release version errors are:
1>FileVersion.obj : error LNK2001: unresolved external symbol __pgmptr
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
|
|
|
|
|
There are both MFC runtime libraries and the C++ runtime library.
The linker error messages appear to relate to the runtime library, not MFC. They look to me like the libs referenced expect the runtime library to be dynamically linked. At least some of them appear to be specific to debugging, which would explain why your later post indicates that these errors go away in your release build.
Note that there are problems if a DLL and and exe are linked to different versions of the runtime library and one tries to release dynamic memory allocated by the other.
josip cagalj wrote: I didn't try to install re-distributable file on target machines.
Any dependencies of your program need to be included in your installation. The target machine may or may not have the appropriate versions of the MFC and runtime library dlls installed. This depends on the Windows version. It can also be impacted by service packs and other software installed on that machine.
josip cagalj wrote: 1>With Release version errors are:
1>FileVersion.obj : error LNK2001: unresolved external symbol __pgmptr
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
This sounds like an issue with the start-up code. Perhaps some sort of confusion between whether you are producing a console app or a GUI app?
Please do not read this signature.
|
|
|
|
|
Thanks for contributing, my app is SDI MFC.
One question just to make my self clear, when I use 'Project > Properties > Linker > Input > Additional Dependencies' entering libmysql.lib mysys.lib strings.lib is this dynamically linking or static. Same question for
#pragma comment(lib, "Netapi32.lib")
#pragma comment(lib, "mpr.lib")
#pragma comment(lib, "shlwapi.lib") entries.
When compiled will exe contain those lib's or do I need to make sure that those lib's exist on target machine by building msi file?
My gold is to have the exe which will contain all necessary stuff to work on win target machine (Win2000, XP, Vista, Win7).
|
|
|
|
|
Hi. my program has ANSI multibyte compilated and uses several Unicode data sources. To convert Unicode to multibyte I use the folowing code:
WideCharToMultiByte(CP_ACP,WC_NO_BEST_FIT_CHARS,sUnic,numb_chars,ansi_buf,numb_chars,NULL,NULL);
This conversion works very fine in All code pages, but on Chinese systems dont works correctly - several characters from end of source unicode string is not converted. Please make happy our chinese clients! Thanks.
|
|
|
|
|
You are using the value numb_chars for the length of both buffers, but that may not be the case. You should use the following sequence to ensure you have enough space for the multibyte string:
int nMBChars;
nMBChars = WideCharToMultiByte(CP_ACP,WC_NO_BEST_FIT_CHARS,sUnic,numb_chars,NULL,0,NULL,NULL);
PTSTR ansi_buf = new TCHAR[nMBChars + 1];
int nMBConv = WideCharToMultiByte(CP_ACP,WC_NO_BEST_FIT_CHARS,sUnic,numb_chars,ansi_buf,nMBChars,NULL,NULL);
See here[^] for full details.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Thanks, Richard! You example code works fine!
|
|
|
|
|
Hi All
I m trying to develop MDI Application in explorer view.
Left side contains a tree view
Right side contains a dialog that will be open when a user clicks on a value in tree view.
Can Anyone provide a tutorial on this ...
Regards
Gany
|
|
|
|
|
That sounds more like a splitter than MDI. If you are using MFC then the CSplitterWnd[^] class should help you. Take a look at the articles here on CodeProject for potential samples.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
|
Hi
Thanks for the info.
But is tutorial is any available to start with ???
consider me as a begineer.
Regards
Gany
|
|
|
|
|
Hi
Any ways to help me>?
Regards
Gany
|
|
|
|
|
I am unsure If I am using my #include directives correctly and where to define my structures.
I have many files that are project independent, a .c and .h and when I want the features I have written in my main.c I #include feature.h as normal. What I wonder is I declare all of the includes that feature needs in its header and sometimes I have another include of the same file in another feature.h as well as my main.c
I know that the compiler is invoked for every separate c file so it will include say function _delay() in every .c file. The linker then puts all the objects together and makes the binary but does it strip the duplicate _delays?? I know the pragma once and other inclusion guards are only relative to that source file being compiled and each source will include the functions.
Along the same lines I have a enum states{Info = 0, Speed = 1}; declared in my header and want to use these states in multiple source files so I include the header when I need it. I also have an initialized structure struct branch the_table[8][5] = { {Control,0,0,0,0,0}, {Speed,0,0,0,0,0} }; and since this structure is using memory I must put it in my source file the problem is I want to be able to access this array outside of its source file and if I declare extern truct branch the_table[8][5]; in the header with the rest of the structure decelerations other source files cannot access its internal structure.
Can someone give some insight onto multiple inclusions upon linking and how to properly declare previously defined structures?
|
|
|
|
|
Trevor Johansen wrote: I know that the compiler is invoked for every separate c file so it will include say function _delay() in every .c file. The linker then puts all the objects together and makes the binary but does it strip the duplicate _delays?? I know the pragma once and other inclusion guards are only relative to that source file being compiled and each source will include the functions.
There is no need to strip the duplicates because there aren't actually duplicate functions (you may include the function declaration in all C source files, provided the function definition -i.e. the function body- is in just one source file).
Trevor Johansen wrote: declared in my header and want to use these states in multiple source files so I include the header when I need it. I also have an initialized structure struct branch the_table[8][5] = { {Control,0,0,0,0,0}, {Speed,0,0,0,0,0} }; and since this structure is using memory I must put it in my source file the problem is I want to be able to access this array outside of its source file and if I declare extern truct branch the_table[8][5]; in the header with the rest of the structure decelerations other source files cannot access its internal structure.
That's the correct way to do it: define the structure in one source file and made it available to other source files using the extern declaration.
As far as you use the #pragma once (do GCC recognize it?) directive (or the oldie-goldie #ifndef ...) to avoid multiple inclusions, I see no problem in your approach.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Ahh I see so my delay.c is compiled to its own object obviously so at link time file1.o and file2.o while both using _delay() get it from delay.o I could have figured that one out if I took the though process a bit deeper eh..
This extern setup is a pain in the butt. I have multiple structures in my files for example I have my menu system as:
enum states {
Info = 0,
Speed = 1,
Up = 2,
Down = 3,
Control = 4,
OnOff = 5,
CW = 6,
CCW = 7
};
struct branch {
enum states new_state:7;
int entry_action;
int action_a;
int action_b;
int action_c;
int exit_action;
};
These are in my header file and almost exclusive to that source file except as the project grew I now need to read branch data from a separate source file. In that file if I include the header I get multiple definition errors of struct branch. Moving that structure to the source and declaring extern struct branch; solves the error but now I cannot use the structure in other source files as it says its undefined.
|
|
|
|
|