 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
I have tried adding MFC support and calling a modal/modeless dialog from a win32 application
My program is crashing when I do this.
Deekonda Ramesh
|
|
|
|
 |
Error message? Code?
The question is very less likely to be understood as it stands now.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
 |
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?
|
|
|
|
 |
Message Removed
modified 21-Jun-16 16:28pm.
|
|
|
|
 |
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.
|
|
|
|
 |
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.
|
|
|
|
 |
As I said, the AdditionalLibraryDirectories path is where it looks for the .LIB file at link time. At run time nothing in your project settings have any meaning to the Windows operating system. When the program loader starts your executable it looks for all the .DLL files that are required. It first looks in the directory where the executable is loaded from, and then in all the directories listed in your system's PATH environment variable. So you either copy your dll into the directory where the .exe file resides, or add its location to the PATH variable.
|
|
|
|
 |
Windows 10, Visual Studio 2012, C++, DLL
I am working on understanding DLLs and reference this article:
http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL?msg=5204076#xx5204076xx
In there I find the phrase:
typedef struct tagXYZHANDLE {} * XYZHANDLE;
I downloaded the code and found only that one instance. I understand tyepdef and struct, but those empty braces throw me. Especially since I found only that one instance. Please point me to something that provides an explanation for what this is doing. Is there a particular name for that type of declaration?
Thank you for your time
modified 28-Feb-16 9:18am.
|
|
|
|
 |
The braces are simply representing a structure with no members. And the *XYZHANDLE means that XYZHANDLE is a pointer to a tagXYZHANDLE structure. It's the fact that they put both braces on the same line that makes it look confusing. Consider:
typedef struct tagXYZHANDLE
{
} *PXYZHANDLE;
In fact, this is how the Windows type HANDLE is declared, as a pointer to an empty structure.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
 |
OK, I see that now. And I see why he did that. I often have a difficult time seeing the obvious. Thank you for pointing that out and taking the time to reply.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
 |
Windows 10, Visual Studio 2012, C++
I have several utilities to put in a DLL and some questions about how to do it.
If the utilities put in a DLL are built without MFC and without ATL, can they be used by those types of projects?
Can the products of multiple projects, within a single solution, be put into a single DLL? So far, my limited experience indicates this is not the case.
Can Visual Studio show the contents of a DLL? I don’t want a reverse compiler/assembler, I just want to see the signatures of the functions contained by the DLL.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
 |
bkelly13 wrote: If the utilities put in a DLL are built without MFC and without ATL, can they be used by those types of projects?
Yes.
bkelly13 wrote: Can the products of multiple projects, within a single solution, be put into a single DLL?
Only if you consolidate the source code into a single project.
bkelly13 wrote: I just want to see the signatures of the functions contained by the DLL.
Only source code or documentation can tell you the function signatures. But the DUMPBIN utility can show you the function names that are exported from the DLL.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
 |
ILMerge is not relevant for unmanaged code.
|
|
|
|
 |
1. Yes, MFC/ATL applications can make calls to C++ functions or class methods, and pure C functions.
2. Yes, but you would need a single project for the final DLL.
3. See Decorated Names[^].
|
|
|
|
 |
1. I expected that and thank you for the confirmation
2. I suppose that is not a big problem, may make for a large project, but that will have to do.
3. I was hoping for something easier, but this also is what it is.
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
|
|
|
|
 |
On point 3 I am sure I once found a tool or some source code (years ago now) that decoded them for you. Try some Google foo.
|
|
|
|
|
|
 |
I am following the example about setting up Direct3D rendering area on this link:
Tutorial 1: Direct3D 11 Basics[^]
All I did is just wrapped it in my own class and instantiated within MFC project.
However, my question is, why no matter what values I put as width/height in the DXGI_SWAP_CHAIN_DESC structure, I still get all window filled with blue?
shouldnt width/height in that structure or in the D3D11_VIEWPORT structure make difference at all?
|
|
|
|
 |
Windows 10, Visual Studio 2012,C++
I need a version of FormatMessage() for Unicode, WCHAR. Google and MSDN deny all my searches for same. I want to call a function of my own that accepts a pointer to WCHAR and the error number, and puts the resultant string in the passed array.
Lacking that, I need a version of swprintf() that has an argument for a max number of characters to move into the string and accepts the LPSTR that is returned by FormatMessage().
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
 |
I presume you mean something like:
void ShowError(DWORD dwError,
PWSTR pszMessage,
int maxMessageSize
)
{
if (dwError == 0)
{
dwError = GetLastError();
}
if (FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), pszMessage, maxMessageSize, NULL ) == 0)
{
swprintf_s(pszMessage, maxMessageSize, L"Error code: %d (0x%X)", dwError, dwError);
}
}
Which you call by:
WCHAR szMessage[512];
ShowError(nErrorCode, szMessage, _countof(szMessage));
wcout << "Exception: " << szMessage << endl;
modified 31-Jan-16 8:59am.
|
|
|
|
 |
Message Automatically Removed
modified 21-Jan-16 9:19am.
|
|
|
|
 |
Message Automatically Removed
modified 21-Jan-16 9:19am.
|
|
|
|
 |
The dot H file contains:
const WCHAR DEFAULT_DlRECTORY[ ] = L"C:\\LOG_FILES\\";
const WCHAR DEFAULT_FILENAME_PREFIX[] = L"Log_File_";
The dot CPP file contains
C_Log_Writer::C_Log_Writer(
const WCHAR *new_directory_name = &DEFAULT_DlRECTORY,
const WCHAR *new_name_prefix = &DEFAULT_FILENAME_PREFIX[0] )
{ ... }
The new_directory_name lines does not compile and produces the error:
Error 1 error C2440: 'default argument' : cannot convert from 'const WCHAR (*)[14]' to 'const WCHAR *' e:\code_tests\common_code_dll\c_log_writer\c_log_writer.cpp 73 1 C_Log_Writer
I thought new_directory_name would be a pointer that would by default point to the first character of the array. Why is that thinking wrong?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 15-Jan-16 17:58pm.
|
|
|
|
 |
Because you're trying to assign a pointer-to-a-pointer to a pointer:
const WCHAR *new_directory_name = &DEFAULT_DlRECTORY
should be
const WCHAR *new_directory_name = DEFAULT_DlRECTORY
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
 |
And that is because DEFAULT_DlRECTORY is an array and passing it as an argument means the address of the first character is passed. Ok, I must confess to being ate up with the dumb ass there.
Thank you for taking the time for a gentle kick in the butt.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|