Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

identifier error

$
0
0

Hlo i'm writing my first bit of code from tutorials, and I have added a .h header file

in the header file I have used the code #include <iostream> using namespace std;

as instructed in the tutorials

however it still gives the error identifier undefined?


Cannot open include file new.h when platform toolset is v140_xp

$
0
0

I'm using the following settings

  • Platform Toolset: v140_xp
  • Target Platform  Version: 8.1 (not changable)
  • Target Platform Windows
  • MFC: Use MFC in a Static Library
  • Runtime library: Multi_threaded(/MT)

But Visual studio 2015 is unable to find the new.h. The windows kits include path is evaluated as "10.0.10150.0\ucrt", but I only have 10.0.10240.0 installed.

Should the IDE use v10.0.10240.0 for v140_xp? If so, how to configure VS2015 to use it? If not, where can I download the v10.0.10150.0?

I have reinstalled the "Windows XP Support for C++" but with no luck.

COM object embedded in html file using Internet Explorer not loading properly

$
0
0

Hi,

We have a COM dll which when embedded in html file and ran on Internet Explorer (Windows 7) was working fine. We were able to make call to the APIs exposed by the COM dll.

    But recently, we installed the windows updates namely KB3074886 andKB3065822.   

    After this, whenever we are accessing the API's of this COM dll, we are getting an error "SCRIPT438: Object doesn't support this property or method: ".  So we tried uninstalling the above two updates and saw that we were able to access the APIs of the COM dll perfectly fine. Only when these updates are installed we are facing the above said error.

     We were able to access the APIs of com dll if we run a standalone application even after these updates. But only when we run the html file on IE, we are seeing this error. 

            Can someone assist us in what may be going wrong here. It will be very helpful for us as it is important for us to run with this updates installed in our system.

Thanks in Advance,


Satyanvesh D

VS2015 c++/cli Form designer parser error.

$
0
0

I've got a project with several forms. It worked perfectly fine, but when I added some timers to some forms (for real time communication with a PLC(programmable logic controller), it gave me the error when I want to check or change something in my designer.

the error that pops up:

C++ CodeDOM parser error: Line: 100, Column: 21 --- Unknown type ''. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built

I've read something about issues when I type something in the designer part:

#pragma region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>


I didn't change anything, before I saw this error. I tried some stuff and commented out some parts. It does work after I comment out every line it complains about. but ye I don't keep much visible of my design after that...

How do i load an rtf file containing image into Rich Edit control

$
0
0
I have been trying to streamin an rtf file that contains an image into RichEdit control. I have implemented the necessary streamin Callback and was able to load the file, but the image have refused to display. I think I have to provide some sort of storage by implementing IRichEditOleCallback::GetNewStorage interface but I don't know how and couldn't find an example code in C++ ( not MFC ). what's the right thing to do, and how.

C++ Project Compiling Error

$
0
0

Hello :) 

i have a project that is made in visual studio 2010 and i want to open it and compile/Build it inside visual studio 2013 and is buggin the compilation..(2 error)

so , is it possible to build a project inside vs2013 from vs2010 ?

if yes what can i do to make it ??

Thxk

RichEdit50W doesn't display "�" character.

$
0
0

I noticed that � character is not displayed in RichEdit50W control. Previous version: RichEdit20W displayed it.

Is there something I can do about it?

Thank you.

Turn ON MDI tab causes memory consumption (eat memory over long marathon run). EnableMDITabs(true, .....);

$
0
0

Dear Visual C++ / MFC group.

Can someone at Visual C++ / MFC group look at MDI client tab (memory consumption) over long period run?

I am currently debug memory consumption (eat memory) over marathon test run. I turn ON MDI tab by called EnableMDITab(....). I have my application run over night and cycle MDI client title text labels. In the morning, I see memory start from 31MB to 90MB in Window Task Manager. If I disabled (Turn OFF) MDI client tab, I only see 31MB. So there are memory consumption some where in the MDI / MFC framework. I have 15 MDI clients windows during long test. In the application, the Application title and MDI client label text changes quite often. By tracking MFC framework, the title update trigger called into CMDIChildWndEx::OnSetText(LPCTSTR lpszText) which in turn called m_pMDIFrame->m_wndClientArea.UpdateTabs(TRUE); and m_Impl.OnSetText(lpszText).

By review the CMDIClientAreaWnd::UpdateTabs(BOOL bSetActiveTabVisible) function, the while loop simply go through all MDI client windows and updated tab icons and tab labels (window caption). If iTabIndex not available, then add new tab into m_wndTab.AddTab(...). So, my investigation by put a debug break point at line 1256: m_wndTab.AddTab(pWndChild, strTabLabel, iIcon); after all MDI client tab already created, however, in long marathon run, I didn't see the debug break. So, now I am thinking of MDI document framework is tracking tab and consumption memory in the MFC/Win32, somewhere that I can't pin point.

Turn MDI client tab OFF:
EnableMDITabs(false);
EnableMDITabbedGroups(false, params);

Turn MDI client tab ON:
EnableMDITabs(true, 0, CMFCBaseTabCtrl::LOCATION_BOTTOM, 1, CMFCTabCtrl::STYLE_3D_ONENOTE);

Thank You

Mike


Hosting a .NET control into an MFC unmanaged app

$
0
0

Hi,

I develop applications in unmanaged VC++ using VS2008. This environment is required by our clients. I need to embed a .NET control into such an existing MFC Application.

I used the following example to make a wrapper calling a C# System.Windows.Forms.Form including the .NET control.

in codeproject.com: Using managed code in an unmanaged application

It works almost fine. No "loader lock" error, I drive the .NET control through the wrapper from my unmanaged MFC app.

The only problem remaining is that the .NET form appears in a separate window when I want it inside my MFC app.

So my question is how do I tell the CView (or CFormView) to have a System.Windows.Forms.Form as its child?

Or is there a side way to make the .NET form appear embedded in the MFC App ?

Visual Studio 2012 C++ Windows 32 Problem

$
0
0

I had to switch to a new computer (64-bit, of course). I installed Visual Studio 2012 as before and opened my projects. I have code which is compiled for 64-bit and for 32-bit windows in two different projects, setting some constants and #ifdef statements. The first is x64 and the second ARM. However, Windows 7 32-bit claims that the second one is not a proper Win32 application and refused to start the EXE (users told me that and I confirmed in an XP installation in a virtual box). However, everything workd fine on my previous computer (a 64-bit computer too) and I did not change a word in the settings or the code.

Now I know that this is difficult to answer without details. But maybe anyone has an idea what could go wrong.

I try to provide some details below:

Compiler Switches: /GS /analyze- /W4 /wd"4100" /wd"4127" /wd"4701" /wd"4703" /Gy /Zc:wchar_t /Zi /Gm- /O2 /Fd"Release\vc110.pdb" /fp:precise /D "WIN32" /D "FLOAT_TEST" /D "DLL" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /D "YACAS" /D "CATCH" /D "PYTHON" /fp:except /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\euler.pch" 

Linker Switches: /OUT:"\euler\euler.exe" /MANIFEST /NXCOMPAT /PDB:"\euler\euler.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "Shlwapi.lib""advapi32.lib" "shell32.lib" "uuid.lib" "comctl32.lib" "winmm.lib" "gdiplus.lib" "wininet.lib" "ole32.lib" "oleaut32.lib" "odbc32.lib" "odbccp32.lib" /STACK:"32000000" /DEBUG /MACHINE:X86 /OPT:REF /SAFESEH /INCREMENTAL:NO /PGD:"\euler\euler.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Release\euler.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1 

The project type is set to "Release" and "Win32". It says "ARM" in the box below the menu bar.

Thanks for any help.

R.G.

PostMessag from Thread to WndProc

$
0
0

I made some Win32 API test program.

#include <Windows.h>
#define IDC_ACQUIRE		(WM_APP + 103)
#define IDC_UPDATE_RESULTS	(WM_APP + 107)
#define IDC_MSG_PREPARING	(WM_APP + 200)

LONG WINAPI WndProc (HWND, UINT, WPARAM, LPARAM);
DWORD ThreadTakingProc (LPVOID lpdwThreadParam );
HWND	m_hWnd;     //Parent Window Handle
HWND	m_hWndMsg;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPSTR lpszCmdLine, int nCmdShow)
{
	WNDCLASS wc;
	HWND hwnd;
	MSG msg;

	wc.style = 0;
	wc.lpfnWndProc = (WNDPROC) WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon (NULL, IDI_WINLOGO);
	wc.hCursor = LoadCursor (NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = L"MyWndClass";
	RegisterClass (&wc);
	hwnd = CreateWindow (
		L"MyWndClass",
		L"SDK Application",
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		HWND_DESKTOP,
		NULL,
		hInstance,
		NULL
	);
	ShowWindow (hwnd, nCmdShow);
	UpdateWindow (hwnd);
	while (GetMessage (&msg, NULL, 0, 0)) {
		TranslateMessage (&msg);
		DispatchMessage (&msg);
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	static HWND hwndButton[5];
	WCHAR wbuf[100];

	switch (message) {
	case WM_CREATE:
		hwndButton[0] = CreateWindow (L"button", L"Create",
				WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
				80, 370, 100, 30,
				hwnd, (HMENU)IDC_ACQUIRE,
				((LPCREATESTRUCT) lParam)->hInstance, NULL);
		m_hWnd = hwndButton[0];

		return 0;
	case WM_COMMAND:
        switch(wParam)
        {
            case IDC_ACQUIRE:
		CreateThread(NULL,		  //Choose default security
				 0,			  //Default stack size
		 (LPTHREAD_START_ROUTINE)&ThreadTakingProc,//Routine to execute
			 (LPVOID)"", //Thread parameter
				 NULL,		  //Immediately run the thread
				 NULL);		  //Thread Id
                break;
	     case IDC_UPDATE_RESULTS:
		unsigned int* l = reinterpret_cast<unsigned int *>(lParam);
		memset(wbuf, 0x00, sizeof(wbuf));
		swprintf(&wbuf[0], L"lParam : ");
		MessageBox(hwnd, wbuf, L"MessageBox",MB_OK);
                break;
        }
        break;

	case WM_PAINT:
		hdc = BeginPaint (hwnd, &ps);
		EndPaint (hwnd, &ps);
		return 0;
	case WM_DESTROY:
		PostQuitMessage (0);
		return 0;
	}
	return DefWindowProc (hwnd, message, wParam, lParam);
}
DWORD ThreadTakingProc (LPVOID lpdwThreadParam )
{
	unsigned int val;
	unsigned int* pval;
	pval = &val;
	*pval = IDC_MSG_PREPARING;
	PostMessage(m_hWnd, WM_COMMAND, IDC_UPDATE_RESULTS, reinterpret_cast< LPARAM >(pval));
	return 0;
}

My intention was to create thread by clicking button.

Thread should PostMessage to the WndProc and WndProc should grab the message and display the value(IDC_MSG_PREPARING = 32968)

However this code doesn't work correctly.

First, compile error occurs in swprintf(I can't find correct UNICODE version of sprintf)

Can anybody make this code work correctly?


SHChangeNotify cause Document item duplicated on explorer siderbar...

$
0
0

Hi Microsoft Developer and everybody, I have a problem when I using SHChangeNotify to update iconoverylay  under specific folder on Windows 10. When I choose user's Documents folder and send notify with following sample code, the Documents item on the explorer sidebar under This PC will duplicate into two item, three item, and more.

#include <windows.h>
#include <shlobj.h>
#include <Shlwapi.h>
#include <tchar.h>

//SHCNF_PATH | SHCNF_FLUSHNOWAIT,
int main(int argc, char **argv) {
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, _T("C:\\Users\\Syno\\Documents"), NULL);
}

You can see the screen record there. It's most every time I run the program, but not always. And I can refresh sidebar with F5 to erase these items.

I tested on other folder like Pictures, Music, and they are all fine, which I can't understand why this happened. I also check system log and debugview which are no error or warning output.

Please help to confirm it's a bug or I use the API in the wrong way or How can I workaround it... LOL

Thank you.

Jack

GetRichEditCtrl().StreamIn breaks on formating.

$
0
0

Found an issue when converting this application Tool from the VC++ 6.0 to VS2013. The error is not an actual error in the code as the code compiles with no "errors" and it works just fine. The program has been adjusted minimally, almost no real change to the code, to allow the program to run and function correctly in VS2013, or so I thought. When we tested the code to read from a external memory device, it displayed the RichText tree in the left pane of the application which seemed to work or function with what seemed to be all the data present, but the Rich Text we are so used to visually seeing was not present in the Right pane of the main application. What peaked my interest was the fact that in the original program you couldn't edit the text, but in our newest compiled program, you could see that the area had not changed from its original state. Almost as if that the data was getting to the application, but for some odd reason was getting dismissed or deleted right before displaying to the pane.

So here's the problem, when the WCARichEdit.cpp does this "

EDITSTREAM es;
es.dwError=0;
es.dwCookie =  (DWORD) &Report;
es.pfnCallback = CBStreamIn;
lStreamReturn  = GetRichEditCtrl().StreamIn(SF_RTF, es);
GetRichEditCtrl().SetReadOnly(TRUE);

It breaks or throws the error 0 unless SF_RTF is changed to SF_TEXT. The code then generates all the data, but the formatting is read into the stream of text. One giant stream that is. We are under some assumption that the formatting in this code is the culprit as to why the text is not showing up when we compile our code. So when the SplitterFrame.CPP does this


Void CSplitterFrame::DisplayReport(CString Report)

{

   CWcaRichEdit*RichEditView = (CWcaRichEdit*) m_wndSplitter.GetPane(0,1);

   CH1_MainteanceToolDoc*pDoc = (CH1_MainteanceToolDoc*)
      ((CMainFrame *)AfxGetMainWnd())->GetActiveDocument();

   RichEditView->DisplayReport(pDoc, Report);
}

The RichEditView->DisplayReport(pDoc, Report) doesn't seem to be getting any code as it just gets zeroed out. This is confirmed by the dwError=0 displaying no change when SF_RTF is left unchanged.

Any Thoughts as to how to get this Rich Text to display?


.NET default ChartArea indexer for Chart component in C++/CLI and .NET 4.0 and later

$
0
0

Hello,

in .NET 3.5 and VS2008sp1  I could use this:

this->chart1->ChartAreas[0]->InnerPlotPosition->Auto = true;

but now, in VS2013 the IntelliSense gives me ERROR that there is only

::default[System::String^]::get instead of Int32 indexer i.e. I must use this sequence

System::Collections::Generic::IEnumerator<System::Windows::Forms::DataVisualization::Charting::ChartArea^>^ ie = this->chart1->ChartAreas->GetEnumerator();
ie->MoveNext();
safe_cast<ChartArea^>(ie->Current)->InnerPlotPosition->Auto = true;

but compiler IS CAPABLE to compile without any error.

Where is problem ? IntelliSense has problem in VS2013 ?  --- as usually ?

of course this code is nice for IntelliSense as well:

System::Collections::Generic::IEnumerator<System::Windows::Forms::DataVisualization::Charting::ChartArea^>^ ie = this->chart1->ChartAreas->GetEnumerator();
ie->MoveNext();
this->chart1->ChartAreas[ ie->Current->Name ]->InnerPlotPosition->Auto = true;

Here is Int32 indexer:  https://msdn.microsoft.com/cs-cz/library/dd468031%28v=vs.110%29.aspx

and here is screenshot:

https://drive.google.com/file/d/0B8m2GdF1vex9OGRfaFZvTUpQU1U/view?usp=sharing

Can someone give me some explanation ?

Thanks.


Linking error in MS VC++ 1.5

$
0
0

Hi All,

I am using MS VC++ 1.5 and I am observing some linking errors.

1. If I use memcpy function I am getting following error while linking 

error L2029: '_memcpy' : unresolved external

However if I include /Ox in compile option this issue is not seen. Also while testing with the following code 

#include<stdio.h>
//#include<string.h>

/*void CopyBuffer(char *dest, char *src, int len)
{
	memcpy(dest, src, len);
}*/

int main()
{
	return 0;
}

I am getting the following linking errors however the compilation is success.

error L2029: '__acrtused' : unresolved external
error L2029: '__aNchkstk' : unresolved external

Can anyone please help me figure out the mistake here. Thanks in advance.



ALT+F4 RegisterHotKey() fails in windows 10

$
0
0

Hi, 

Generally ‘Alt + F4’ is a system short-cut key is used to close the standard Window’s application. For one of our Window’s application (which is a 32-bit application) (at a particular instance of time) we want to disable the ‘Alt+F4’ system key. 
We are using the below Windows API to achieve this.
  ::RegisterHotKey(hWnd, atm, MOD_ALT, VK_F4);
  Reference : https://msdn.microsoft.com/en-us/library/windows/desktop/ms646309(v=vs.85).aspx 

This API works perfectly in WinXP, Vista, Win7 (64 and 32 bit) but it is not working in case of Windows 10.

Related information : 
After initial investigation we came to know that ‘ALT+F4’ was not functional for the Windows command prompt before Windows 10. 
For Windows 10 the ‘Alt+F4’ can be used to close the command prompt. Is this improvement related to above mentioned issue ?

Hardware :
HP Z440

Software:
Windows-10 64 bit Professional 

Thanks in advance,

Apurva

How to define a variable as ws2ipdef.h in6addr_loopback do?

$
0
0

In windows SDK ws2ipdef.h, we can link to a variable in6addr_loopback.
Look into the declaration of in6addr_loopback

extern CONST IN6_ADDR in6addr_loopback;

How can I achieve the same functionality without __declspec(dllimport)?

I checked with ws2_32.lib with dumpbin,
020 00000000 SECTB  notype       External     | _in6addr_loopback
021 00000000 SECTC  notype       Static       | .rdata
    Section length   10, #relocs    0, #linenums    0, checksum 4D8FC412, selection    1 (pick no duplicates)

Sample code for this?

Thanks a lot,
    J. J. Lee


Source code is built using Visual C++ 2013 RTM version and runtime is Visual C++ 2013 update 5

$
0
0

I have a basic question.

Development Environment :

I used Visual Studio 2013 RTM version to build my C++ source code.

Production Environment :

Will the exe's and dll's created using Visual Studio 2013 RTM version will run on Visual C++ 2013 redistributable package of Update 5 ?

What is the recommended guidelines?


How to clear DrawText?

$
0
0

In my Win32 API program, draw text using DrawText() function on the "static" control.

Some messages should be displayed on this "static" control.

I drawed text in the following function.

void DisplayText(HWND m_hWndStatic, LPARAM lParam)
{

    PAINTSTRUCT ps;
    wchar_t wbuf[100];
    RECT	rect;
    HFONT	hFont, hTmp;
    HDC		hdc;
    hdc = GetWindowDC(m_hWndStatic);
    GetClientRect (m_hWndStatic, &rect) ;
    SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
    SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
    rect.left=0;
    rect.top=0;
    hFont = CreateFont(80, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 2, 0, L"SYSTEM_FIXED_FONT");
    hTmp = (HFONT)SelectObject(hdc, hFont);
    memset(wbuf, 0x00, sizeof(wbuf));
    switch(lParam)
    {
	case IDC_MSG_PREPARING:
		_swprintf(wbuf, L"--- Preparing ---");
		break;
	case IDC_MSG_STATUS1:
		_swprintf(wbuf, L"--- 1 ---");
		break;
	case IDC_MSG_STATUS2:
		_swprintf(wbuf, L"--- 2 ---");
		break;
	case IDC_MSG_STATUS3:
		_swprintf(wbuf, L"--- 3 ---");
		break;
	case IDC_MSG_STATUS4:
		_swprintf(wbuf, L"--- 4 ---");
		break;
	default:
		break;
    }
    DrawText(hdc, wbuf, -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
    DeleteDC(hdc);
}

My problem is that the text is overlapped like following screen capture.

I want to clear text previously drawn prior to DrawText().

How could I do this?

Using strchr

$
0
0

In the function reference for strchr on MSDN:

https://msdn.microsoft.com/en-us/library/aa272957(v=vs.60).aspx

I'm not understanding why, in the example, they subtract "string" in "result", eg, result = pdest - string + 1.

I think I understand everything else in the example, but it doesn't make sense to me to subtract string.

Thanks!

Viewing all 15302 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>