|
I am having an MFC Dialog class called CDataFilesDialog
inheriting from CDialog
I have a global object of this dialog named dlg;
I am doing a dlg.DoModal() from a WMCOMMAND message handled by wndproc of my win32 application. I am trying to mix MFC and WIn32
Deekonda Ramesh
|
|
|
|
|
I strongly suspect that your entire application needs to be re-built as MFC in order to do this.
|
|
|
|
|
SInce MFC is a wrapper of win32 , why can't I do this?
Deekonda Ramesh
|
|
|
|
|
Because the design of MFC means you can use ordinary Win32 calls inside an MFC application but not the other way round.
|
|
|
|
|
Under Windows, I try to open file which name contains apostrophe or some letters in language other than English. In these cases fopen or CreateFile (from W32 library) fail to open it. How should I do that task? Wide character type, wfopen or defining UNICODE don't help. The functions say the file doesn't exist.
|
|
|
|
|
I just tried a file named "foo'baÇÉØr.txt" and it opened fine. You must have some other issue with yours.
|
|
|
|
|
Well, maybe. I read the name of file from another text file which is windows media player list (.wpl). E.g. I can't open file named "Baby,_I’m_Not_Sure_If_This_Is_Love.mp3" but this "05 - Cold Hearts.mp3" can be opened. There may be issue with encoding characters in the list but how it is possible that some files can be opened and others cannot from the same list. Of course, all files are playable by WMP.
|
|
|
|
|
|
Additionally, here is what I see in debugger window as contents of the variable which contains the file name:
"Baby,_I’m_Not_Sure_If_This_Is_Love.mp3"
|
|
|
|
|
That looks like UTF-8. XML files are usually UTF-8 encoded.
So you must convert from UTF-8 to wide characters after reading the file content into memory (e.g. using MultiByteToWideChar function (Windows)[^]).
Afterwards you must still check for entities as noted in my above post. Even when the WPL file does not use entities for non-ASCII characters it uses them for the reserved characters (quot , amp , apos , lt , and gt ).
|
|
|
|
|
Definitely, it helped at least in half a problem. The rest lays in XML entities like &_amp_; (without underscore). I think I should treat them manually.
Generally, mbstowcs won't help. I had to use win32 function where I can define more encoding standards.
|
|
|
|
|
I just created a file with that name and I was able to open it with another application. As I said before, I suspect the issue is something else. Are you sure that your path is correct when you try to open the file?
|
|
|
|
|
Write a C
Program to find the survivor in a "7 up" game.
In the game, a group of people stand in a circle,and start counting from 1 in a clockwise direction.
The person who has to say "7" goes out, and the person next to him starts counting from 1 again.
This goes on until only one person remains, and he is survivor. Your goal is,
given the size of the group find out the place(Index) in which a person has to stand for him to become the survivor
|
|
|
|
|
You posted this in the wrong forum. Ask a question[^] or C / C++ / MFC Discussion Boards - CodeProject[^] would be the right places.
But note that you won't get an answer for this kind of request. This is not a code writing service. Try it yourself. If you then get stuck at some point, show what you have tried so far (code snippets), describe the problem, and you might get valuable help.
|
|
|
|
|
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Hi,
I want to send raw esc/pos (epson compatible) text data (not graphics) to a cheap chinese POS58 thermal printer using either MFC or Console32 application. Is there any library or sample to start of ?
Regards,
sdancer75
|
|
|
|
|
|
I have a very general question on database migration. Am pretty new to database development and have no ideas at all, so please bear with me.
I am working on a VC++ MFC application using Visual Studio. This has a Oracle backend database.
There's a table called T_SIGN_IN that has the following columns,
1. USR_NAME
2. USR_ID
3. USR_ACCT_NUMBER
4. USR_ADDRESS
5. USR_SSN
6. USR_LAST_LOG_IN
7. USR_LAST_LOG_OFF
............and so on...
Now as part of a new feature enhancement, we want to create a new table called T_SIGN_LOG and migrate some of the existing column data from T_SIGN_IN.
For e.g., we want to move data from USR_ID, USR_LAST_LOG_IN and USR_LAST_LOG_OFF to the new table.
How can this be achieved?
I hear that there're 2 ways of achieving this.
1. Stored Procedures.
2. C++ function.
Can someone give me a example of how this can be done via the above 2 approaches? Code snippet will be great!
And also, which is the best way of doing it?
|
|
|
|
|
|
I am trying to build and use my first DLL. After editing in the source code and building the Debug directory contains the .dll, the .lib and four additional files. A console app is created in the same solution but another project and built without referencing the dll. The .dll and .lib are copied to the solution directory. In the console app I added:
Quote: #include "E:\CODE\Common_Utilities\Common_Utilities\Common_Utilities.h"
Ctl-F7 produces a successful compile. A build produces this error.
Quote: Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl Get_Text_For_Error_Code(unsigned long,wchar_t *,unsigned int)" (__imp_?Get_Text_For_Error_Code@@YAXKPA_WI@Z) referenced in function _wmain E:\CODE\Common_Utilities\Test_Get_Text_For_Error_Code\Test_Get_Text_For_Error_Code.obj Test_Get_Text_For_Error_Code
After some searches my latest attempt to fix is by: Right click solution -> Properties -> Linker -> General -> Additional Library Directories
There I edited in the path to the DLL. No help.
This is my first DLL attempt and I strongly suspect there is something simple I have missed. Please point me in the right direction.
Thank you for your time
|
|
|
|
|
At link time you need to include the .lib file, which contains the exports from the build of the library. The .dll file is only used at run time whan the system loader gets all the separate modules into the program's address space. Did you follow the guide at Walkthrough: Creating and Using a Dynamic Link Library (C++)[^]?
|
|
|
|
|
I had not found that one, but went through it. I read the instructions, adapted the steps to my solution as I understand them, and the project in the same solution that used the DLL worked perfectly. That is cool.
However, I noted something. From that walkthrough web page is this:
Quote: To use in the app the math routines that you created in the DLL, you must reference it. To do this, select the MyExecRefsDll project in Solution Explorer, and then on the menu bar, choose Project, References. In the Property Pages dialog box, expand the Common Properties node, select Framework and References, and then choose the Add New Reference button. For more information about the References dialog box, see Adding references in Visual C++ projects.
When I arrived at the dialog to add a reference the only allowed option was the DLL in the same solution. I created another solution in another directory to test using the DLL from another directory and solution. I navigated to same place within the IDE and the new solution with:
Quote: right click solution -> References -> Add New Reference
The response is "No items found." The dialog offers no method of discovering a DLL somewhere else on the computer. There is still something simple I am missing.
How does one specify an arbitrary DLL to use as a procedure or class resource?
Edit: From the new solution I tried this: in the dot cpp file, console app, I added this line:
#include "E:\CODE\Common_Utilities\Common_Utilities\Common_Utilities.h"
It is a reference to the h file from the solution where the DLL was created. In that new console app I called a function from the DLL. Then the following steps were taken:
Quote: Right click on solution followed by: Properties -> configuration Properties -> Linker -> General -> field Additional library directories.
In that field I edited in the location of the dll from that dll solution. The compile succeeds but the link continues to fail with error LNK 2019 unresolved external symbol and __delspec(dllimport)
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 29-Feb-16 22:09pm.
|
|
|
|
|
You are still (not surprisingly) missing an important part of this. When you create a DLL the build (more specifically the linker) creates two files.
The first file is the DLL itself which contains the actual code that you want to call when your program is run. This file is only ever needed at run time, it has no part in the linking process when creating your executable.
The second, equally important, is the .LIB file, which contains the names and offsets of the exported functions. This second file is the one that you must add to your project in order for the linker to satisfy all the __delspec(dllimport) declarations. So when you add to the Additional library directories the path to your library, you also need to add the name of the .LIB file to the Additional Dependencies part of the Input section in the Linker properties.
Of course, you could save yourself much of this pain by creating a static library rather than a dll, but that is probably an exercise for another day.
|
|
|
|
|
My next step then is:
Right click the project level containing the code that uses the DLL and select:
Properties -> Configuration Properties -> Linker -> Input
There is found the field Additional Dependencies. Currently it contains:
kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
edit in:
Common_Utilities.lib
and click OK.
The project built successfully. Great! I try to run it and get a dialog stating:
Quote: The program can't start because Common_Utilities is missing from your computer. Try reinstalling the program to fix this problem.
Ok, going back to: Solution -> Properties -> Configuration Properties -> General and field:
Additional LIbrary directories I find this text:
Quote: E:\CODE\Common_Utilities\Debug;%(AdditionalLibraryDirectories)
That is indeed the path of the directory that contains the DLL. I don't understand why it says the DLL is missing.
Good grief, I really wish I knew someone that knows this stuff and could sit here and say: Right there, change that.
Thank you for your time
|
|
|
|
|
Make sure the Common_Utilities DLL is in the same folder as the executable so the system can find it.
The Additional Libraries setting tells it where to find the LIB files.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|