|
|
I implemented a multi language UI in a MFC program, since only a few controls, so I write translation in code, I knew it can be implemented with DLL, or String Table.
Now I wonder what way is better, in code, string table, or DLL,according to run time performance and space consuming.
|
|
|
|
|
If your program isn't huge, no reason to do this in an external library, that would definitely be the slowest and most (disk) space consuming method.
I'd say string table would probably be fast, and as long as you don't have too many strings, it shouldn't be too costly. If you have a huge number of strings, you may start using up quite a bit of memory to support this, then the library method starts to become more appealing.
|
|
|
|
|
Hello everyone,
I meet a crash problem. just as following, I donot know why IsWindow will crash,
Is there anyone meet the same problem?
AULTING_IP:
user32!IsWindow+1a
761a7150 8365fc00 and dword ptr [ebp-4],0
EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 761a7150 (user32!IsWindow+0x0000001a)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: fffffffc
Attempt to write to address fffffffc
ChildEBP RetAddr Args to Child
06f9ff48 72d229bb 04e73a50 6928d287 00000000 user32!IsWindow+0x1a
06f9ff80 72d22a47 00000000 7710338a 04e74990 msvcr80!_callthreadstartex+0x1b [f:\sp\vctools\crt_bld\self_x86\crt\src\threadex.c @ 348]
06f9ff88 7710338a 04e74990 06f9ffd4 776b9f72 msvcr80!_threadstartex+0x66 [f:\sp\vctools\crt_bld\self_x86\crt\src\threadex.c @ 326]
06f9ff94 776b9f72 04e74990 70af11ab 00000000 kernel32!BaseThreadInitThunk+0xe
06f9ffd4 776b9f45 72d229e1 04e74990 00000000 ntdll!__RtlUserThreadStart+0x70
06f9ffec 00000000 72d229e1 04e74990 00000000 ntdll!_RtlUserThreadStart+0x1b
|
|
|
|
|
Please show the code that causes the error, it looks as if you are passing a bad parameter to some windows function.
|
|
|
|
|
Further questions:
- the window handle you feed into IsWindow: is it a handle inside your application or a different window?
- is your application running elevated?
- is the other application running elevated?
- are there differences in 32 vs. 64bit architecture between the applications?
|
|
|
|
|
Windows XP, Visual Studio 2008, MFC, Cpp
Note: I am hoping that someone recognizes this basic class of problems and can advise me without additional details. If needed, tell me what additional details are required.
I cannot copy/paste from my working computer so please excuse any obvious typos.
Basic Problem:
I added a simple stand alone function to my project and cannot get Visual Studio to compile it.
Setup:
Application AR2_IADS_Client_Simlulator is located in E:\VISUAL_STUDIO\AR2_IADS_Client_Simulator.
This directory: E:\VISUAL_STUDIO\COMMON_CODE contains classes and code that is used by multiple solutions and projects.
In the Solution Explorer, project AR2_IADS_Client_Simulator I right clicked on the Header Files part of the project and added a new dot h file named: Log_One_TCP_Packet.h. It was placed in the COMMON_CODE directory. It looks like this:
#include "stdafx.h"
#include "C_Log_Writer.h"
Void Log_One_TCP_Packet( … arguments );
The same was done in section Source Files and file Log_One_TCP_Packet.h.cpp was also created in COMMON_CODE. It begins like this:
#include "stdafx.h"
#include "Log_One_TCP_Packet.h"
Void Log_One_TCP_Packet( … arguments )
{ … }
Action:
The cpp file is open in VS and is in focus. Press ctl-F7 to compile it.
The error messages state:
Quote: Warning C4627 #include “stdafx.h” skipped when looking for precompiled header use.
Warning C4627 #include “Log_One_TCP_Packet.h” skipped when looking for precompiled header use.
Fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include “stdafx.h”’ to your soruce?
I don’t know of any option such as: #include_and_do_not_skip “Log_One_TCP_Packet.h”
There is no button I can select that says: “No! I did not forget. Its right there in the source code.”
There are already several classes in COMMON_CODE used by this project. The directory is referenced in
Quote: Properties -> Configuration Properties -> C/C++ -> Additional Include Directories.
Questions
Must this function be made into a stand-alone class just for this one function?
How might I get VS to recognize and compile it?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
Did you try cleaning and rebuilding the whole project?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Rats. Its so easy to forget the easy stuff. No, I did not. I will try that at work tomorrow. But I did make a class out of it and that worked just fine.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
IIRC you get this - or at least a similar - chain of warnings/errors when your first include does not match the precompiled header setting for the file.
Check that the precompiled header setting for this file actually is "stdafx.h", not another one.
|
|
|
|
|
I'm stuck here on how to compile the following code, i need to put a struct which contains std::unique_ptr into std::map, but i always get the error message, anybody can help me?
Quote: e:\console.cpp(21): error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>'
1> with
1> [
1> _Ty=int
1> ]
1> d:\programfiles\vs 2010\vc\include\memory(2347) : see declaration of 'std::unique_ptr<_Ty>::unique_ptr'
1> with
1> [
1> _Ty=int
1> ]
1> This diagnostic occurred in the compiler generated function 'Baa::Baa(const Baa &)'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.28
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
here is my code:
#include <iostream>
#include <memory>
#include <vector>
#include <map>
struct Baa {
std::unique_ptr<int> x;
Baa() {
}
Baa(Baa&& o)
{
x = std::move(o.x);
}
Baa operator = (Baa&& param)
{
x = std::move(param.x);
return *this;
}
};
int main()
{
std::map<int, Baa> sheep;
Baa ba;
sheep[0] = ba;
}
|
|
|
|
|
which compiler you use? with what options?
|
|
|
|
|
|
the problem is simple. The code
sheep[0] = ba; should be
sheep[0] = std::move(ba); Your first approach used the copy constructor to copy the unique_ptr this defeats the purpose unique_ptr.
Also another issue is:
Baa operator = (Baa&& param) should be
Baa& operator = (Baa&& param)
|
|
|
|
|
Visual Studio 2008, MFC, C++, Windows 7 and Windows XP
My project uses WCHAR and a dialog needs a CListBox. But CListBox does not like wchar_t or WCHAR. In particular, method AddString(). My searches have not discovered a CListBoxW or anything that looks like wchar_t methods. What is the proper control to use that performs the CListBox operations?
I see that CString will work, but then the WCHAR must be converted to CString. Must that path be taken?
Resolution: I was certain Unicode was selected. I was wrong, MBCS was selected. Changing that to Unicode resolved the apparent inconsistencies.
Thank you for your time
modified 29-May-15 9:59am.
|
|
|
|
|
Change the Project Settings to build Unicode build. This will make CString and CListBox become Unicode
|
|
|
|
|
According to the CListBox documentation[^], the AddString method takes a LPCTSTR parameter; that is, a pointer to a TCHAR[] . If your project is built for Unicode that will be equated to LPCWSTR which is a pointer to a WCHAR[] .
|
|
|
|
|
Hello,
My project is MFC and does and did have Unicode set. Right now, things are rather funky and I don't understand. For example
CString a;
CString b;
b = "test";
a.Format( "%s", b ); // does not compile.
a.Format( L"%s", b ); // does compile.
A search found a tutorial that shows use without the L prefix.
So I went back to the WCHAR concept and now it works.
I really wish I was not the only one here working with C++.
Thank you for taking the time to reply.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
If you are working in Unicode the the Format statement requires that the format string be declared as Unicode, with either the L prefix or TEXT() macro, thus:
a.Format( L"%s", b ); a.Format( TEXT("%s"), b );
Also, you should use upper case S to indicate that the contents of b is actually an ASCII, rather than Unicode, string.
bkelly13 wrote: I really wish I was not the only one here working with C++. You are not, if you look in the C/C++ forum you will see fairly regular questions.
|
|
|
|
|
Hello Richard,
This morning I determined that some code using CString compiled in Debug mode but not in Release mode. That was really puzzling. After messing around I discovered that I had multibyte character set enabled rather than Unicode. It explained some other problems I had since I was sure Unicode was selected. Now I am back on a path of progress.
I was not clear in my last statement of my previous post. I really wish I was not the only one at this work site working with C++. There is an Oracle data base guy and five people working on a specialized script for processing telemetry data. Most of them know C# and they disdain C++.
I'll stick with Unicode.
I am thinking of dropping WCHAR and going to wchar_t. Is that a good or bad idea? Or maybe indifferent?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
bkelly13 wrote: and they disdain C++. Thanks for clarifying Bryan; seems you really are the one with the tough part of the job.
bkelly13 wrote: dropping WCHAR and going to wchar_t Indifferent really, as WCHAR is just a typedef for wchar_t , probably a hangover from the days before C++. I know that going from ASCII to Unicode is initially a bit of a pain, but it is probably the right decision for the long term.
|
|
|
|
|
|
What?!
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have added dual interfaces to an existing class in MFC application but when i run the client the cocreateinstance is failing with the error 0x80080005 (CO_E_SERVER_EXEC_FAILURE) Server execution failed. I had followed the steps from the articles below:-
http://www.codeproject.com/Articles/8202/Adding-automation-to-MFC-applications.
https://msdn.microsoft.com/en-us/library/4h56szat.aspx[^]
Hide Copy Code
hr = ::CoCreateInstance(CLSID_Application, NULL, CLSCTX_LOCAL_SERVER, IID_IApplication, (void**)&m_IApplication);
if (SUCCEEDED(hr)) {
if (m_IApplication)
{
m_IApplication->Show();
}
}
|
|
|
|
|
Check the even log for the details.
|
|
|
|