|
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.
|
|
|
|
|
As topic says, I'm having some HItTest issue.
Background:
I'm making a windows mobile ce 6.5 application.
There is some resource based dialog with ListView on it.
I'm subclassing the ListView with "CustomLVCtrl" and HeaderCtrl with "CustomHCtrl".
Both custom controls have increased height based on some constant value.
Now about my problem:
From WM_GESTURE GID_HOLD handler i'm getting some screen coordinates and then testing if any ListView item is being hold.
The problem is that i'm never getting a valid item index. It looks like item with index 0 is under the header, because testing first item results in 1, second returns 2, ..., then last returns -1. These results are not accurate for the whole item height either.
Simplified code:
void Controller::onHold(int x, int y)
{
CPoint point(x, y);
view_->list_.ScreenToClient(&point);
LONG dlgBaseUnits = GetDialogBaseUnits();
int baseunitX = LOWORD(dlgBaseUnits), baseunitY = HIWORD(dlgBaseUnits);
point.x = ATL::MulDiv(point.x, 4, baseunitX);
point.y = ATL::MulDiv(point.y, 8, baseunitY);
LVHITTESTINFO lvhti;
lvhti.flags = 0;
lvhti.pt = point;
int nItem = view_->list_.HitTest(&lvhti);
if (lvhti.flags & LVHT_ONITEM)
{
ShowModal(nItem);
}
}
I've also tried with
RECT rect={0,0,4,8};
MapDialogRect(hwnd, &rect);
int baseunitX = rect.right;
int baseunitY = rect.bottom;
point.x = ATL::MulDiv(point.x, 4, baseunitX);
point.y = ATL::MulDiv(point.y, 8, baseunitY);
but with same results. Can anyone point out what I'm doing wrong?
|
|
|
|
|
Visual Studio 2008, C++, MFC
lang="cs">
const char build_date[] = __DATE__;
swprintf_s( my_date, my_size, L"%s", build_date );
swprintf_s( my_date, my_size, L"%ls, build_date );
show_date.SetWindowTextW( my_date );
show_date.SetWindowText( __DATE__
show_date.SetWindowText( L"this displays" );
String my_date does not contain the date that is found in build_date. Multiple versions have been tried and not successful in getting compile date to display in the dialog. All the searches I have done tell me this should work.
What must be changed?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 24-Apr-15 8:02am.
|
|
|
|
|
You are using the wide character version of swprintf_s , but your date string is char type, so you need to use the upper case S in your format string so it gets converted to Unicode, thus:
swprintf_s( my_date, my_size, L"%S", build_date );
|
|
|
|
|
That was it. Thank you.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|