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

Does /v120_xp switch supports Windows XP 32-bit RTM, SP1, SP2?

$
0
0

Hi, My team is considering migrating Visual Studio 2013 from 2008.
I found that v120_xp switch (v110_xp in 2010) enables XP support on MSVCRT.
But I'm wondering if it only supports XP SP3 (in 32-bit), not SP2 or prior.

Most of our client still uses WinXP, some of them is still not applying SP3.

so we must support XP SP2 at least.

Which is correct? Does v120_xp switch supports only SP3? or can it be used prior SP2?



Localize Windows buttons (minimize, restore and close) tooltip

$
0
0

Hi All,

We have localized our software(English and Hindi) and have localized every control name, tooltip, menu items name and etc. Now I am facing the problem with Windows button (minimize, restore and close) tooltip. The tooltip for these buttons still shows in English even if Software is opened for Hindi. All other things are showing in hindi except the tooltip of these windows buttons. Please see the minimize button tooltip (in english) in mentioned image.

Please suggest me any way that How can I localize tooltip of these buttons?

The problem about CString & 0xFFFF

$
0
0

I met a issue when i use CString to store some specified bytes. i created a new 'Win32 Console Application' project with VS2010, checked the MFC. My question and source 

            CString str;
            TCHAR* p = new TCHAR[31];
            p[0] = 0xFFFF; //it will not the issue later if i change p[0] = 0xFFFB.
            p[1] = _T('A');
            p[2] = _T('A');
            p[3] = 0;
            CString strP = CString(p); //Result:strP == “AA”  
 
            str.Format(_T("%s--%s"), _T("ab"), strP); //Result:str == “”, Why? It's not what i expected.  
 
            str = _T("ab--") + strP; //Result:str == “ab--AA”,It is what i expected.
             
            delete[] p;


Send data from VC++ application to USB device

$
0
0

Hi,

I need to send data from application to a "USB serial device".

Application has been developed in VC++.

Please guide me with suitable sample code on how I can do it.

Thanks in advance,

Alex

What is exactly the problem with this simple C++ code in VS2013?

$
0
0
#include<iostream>
int main()
{
    const char* p = "ab中国"; //  中 = \u4e2d  国 = \u56fd
    std::cout << p << '\n';
}
  1. By clicking the source file name in the solution explorer with the mouse right click and selectingOpen With >> Binary Edit, one can see that the source file is encoded in UTF-8 with signature (look at the BOM at the start of the file).
  2. One can also see on this binary image of the file that the literal string is correct in the source code, as follows:
      a    b       中             国
    61  62  E4 B8 AD  E5 9B BD

    where E4 B8 AD is the UTF-8 encoding for the character 中 = \u4E2D  and E5 9B BD is the UTF-8 encoding for the character
    国 = \u56FD.
  3. However, if you debug with a break in the expression

    std::cout << p << '\n';

    you'll verify that the character string obtained by the compiler is given by the bytes 61 62 3F 3F 00,
    which is clearly a bug.

But what is exactly the problem here? Is it that the compiler doesn't work correctly with a source file encoded in UTF-8, or might there be some other explanation?

How to disable a single row from a CListCtrl?

$
0
0

Hi

I am using report view of clistctrl and in my requirement i want to disable only a single row.

Thanks and regards

ewas

Complete minimum working example of CListBox in pure MFC

$
0
0

I can not find a minimum working example of pure MFC CListBox. The closest example provided in this forum was [Working with CListBox correctly] and the example code did not even use CListBox at all, nor did it ever use the CListBox::AddString member function. 

All of the numerous examples that I found online were not complete, each one of them always left out a crucial step. It seems that the problem I am having is identical to the problem addressed in [Working with CListBox correctly], debug assertions are failing when attempting to invoke CListBox::AddString(). 

I really need a complete and minimum working example of using CListBox in a pure MFC application in Visual Studio 2008. 

The closest thing that I could find was a Visual C++ 6.0 example that used an array of six CListBoxes. This was too complex to fully understand.  

It would really be great if Microsoft provided [complete and minimum working examples] of every graphical user interface object. This would reduce several days of research down to a few minutes of adapting the example code. 


100% Accurate Display Screen OCR http://www.OCR4Screen.com

IE 11 crashes when calling Real_getaddrinfoExW() function

$
0
0

Hi All,

IE 11 in Windows 8.1 (64-bit OS) crashes when calling "Real_getaddrinfoExW()" function, and the module name in event viewer shows "webio.dll". Anyone please help me to overcame this issue.

Thanks,

R-VR


Non-Copyable Mixins in Visual C++

$
0
0

I would like to know more about Noncopyable Mix-ins and which examples and real-world applications do they work with?

I found this out along with this link:

http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Non-copyable_Mixin#Known_Uses

Since that I have several books in C++ in my own pad, not all tutorials are the same.

I have found some information regarding what was in my previous thread.

Can anybody provide me some examples when users try to utilize the Non-copyable mix-ins with the fstream header library?

Maybe someone who can assist me and can provide me some examples regarding this issue.

By the way, I had to clean up some messy code by getting rid of this function - NoImplicitCopy() that is within the link above.  Finally I compiled it, and it worked fine.

Does it protect the entire source code by using the explicit copy constructor only, as well as it protects and assigns mutable parameter types as well?

Should the explicit copy constructor alter the file access configurations in C++ exclusively?

Any feedback as well as some full detailed examples will be fine.

I have altered the following code a bit:

void bar(NoImplicitCopy &n) 
{
 string FileX;
 cout << "Enter the file name you want to protect:   ";
 cin >> FileX;
 ofstream xfOut(FileX);
 xfOut.open(FileX);
 xfOut.close();
}

int main(void)
{
 NoImplicitCopy n;
 NoImplicitCopy x(n);       // Explicit copy.
 bar(n);
 return 0;
}

Although it compiles and runs well, anyone is welcome to make changes to it just to make it better for files exclusively.

JohnDBCTX




Xinput.h causing No Target Architecture

$
0
0

I'm having an issue where adding the line:

#include <XInput.h>

is causing an error shown as following:

1>c:\program files (x86)\windows kits\8.1\include\um\winnt.h(147): fatal error C1189: #error :  "No Target Architecture"

I have tried running the same program without that single line and appears to work fine.
Any help or suggestions would be greatly appreciated. I'm only a student learning C++ so simple instructions would be best.

.Res File

$
0
0

I ran a file recovery program on my sd card and it worked but saved the files in .RES and I can not open it. I am in need of help. The easiest the explanation the better.

Please help!

Remote Desktop Screen capture

$
0
0

Hi all, I want to connect remotely to a client desktop, take a screen capture of that desktop, resize the image to fit a specification, and return the image as a bmp for other functions to use.

For taking a screenshot, I am planning to use this.

http://support.microsoft.com/kb/186736/en-gb

But how is C++ going to know the correct desktop to print? What function am I supposed to use for it?

Any comments will be appreciated. Thank you!!!


Can I access to OnPaint of CChildView class in a thread that belongs to CMainFrm class?

$
0
0

Hello, I am Hoon-sup, Kim as a beginner for multi-thread.
I would like to use multi-thread MFC code which are consist of three threads(DAQThread, DSPThread, DRAWThread). As you can see in the bottom of this letter, there are three files which are MainFrm1.h, MainFrm1.cpp and ChildView1.cpp. This code can play a role in acquiring CCD camera data and then signal processing of it and last drawing the resultant image of it. When I push the play button, OnDaqOctplaying() function is called and the play button is toggled into stop button and the display shows me real time image at 10 frames per sec correctly.  However, as I want to finish the thread operation, and when I push the stop button which goes into botton part in OnDaqOctplaying(), 126byte size memory leak error occurs because the DRAWThread is terminated forcefully as you can see in the Debug mode Output display. I used global variable such as DAQThreadFlag, DSPThreadFlag and DRAWThreadFlag to finish each thread by itself. However I don't know why the DRAWThread is not finished by itself. I want to know whether it is correct that I am calling RedrawWindow() function in DRAWThread which belongs to CMainFrm class. 

CChildView *pView = (CChildView *)pParam;

pView->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);

Is it correct thatI use CChildView *pView when I want to call OnPaint() function of CChildView class in a thread of CMainFrame class?

When I try to finish DRAWThread by itself via global variables, it seems like deadlock and then finally WAIT_TIMEOUT happened.

According to a book about MFC multi-thread, it is said that when we need to access to Main frame window or View window in a specific worker thread under multi-thread, User defined message is recommended to use. For examples,GetActiveView()->PostMessage(....) But there is no any reason why I use User defined message in this situation and I have no any idea about how to implement it in detail.

Please let me know which part or structure of the code that I attached is not correct and do I need toexplicitly write NULL to Handle of DRAWThread right before finishing it?

Thank you very much any way. 


----Debug mode Output display:----------------------------------------

DAQ Thread End
The thread 'Win64 Thread' (0xd50) has exited with code 0 (0x0).
pDAQThread is terminated normally
pDAQThread is terminated(code=0)
DSP Thread End
The thread 'Win64 Thread' (0x17b4) has exited with code 0 (0x0).
pDSPThread is terminated normally
pDSPThread is terminated(code=0)
pDRAWThread is terminated FORCELY!!!
The thread 'Win64 Thread' (0x17c8) has exited with code 0 (0x0).
pDRAWThread is terminated(code=259)
The thread 'Win64 Thread' (0x17f4) has exited with code 0 (0x0).
all thread finish?...
Warning: no message line prompt for ID 0x800C.
Warning: no message line prompt for ID 0x800D.
Warning: no message line prompt for ID 0x801F.
Warning: no message line prompt for ID 0x800E.
Warning: no message line prompt for ID 0x800F.
Warning: no message line prompt for ID 0x8010.
Warning: no message line prompt for ID 0x8011.
Warning: no message line prompt for ID 0x801B.
Warning: no message line prompt for ID 0x800C.
Warning: no message line prompt for ID 0x800D.
Warning: no message line prompt for ID 0x801F.
Warning: no message line prompt for ID 0x800E.
Warning: no message line prompt for ID 0x800F.
Warning: no message line prompt for ID 0x8010.
Warning: no message line prompt for ID 0x8011.
Warning: no message line prompt for ID 0x801B.
The thread 'Win64 Thread' (0x1588) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x9ac) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0xc48) has exited with code 0 (0x0).
I am OnDestroy!!!
The thread 'Win64 Thread' (0xc20) has exited with code 0 (0x0).
Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp(306) : {1318} client block at 0x00000000074DFC00, subtype c0, 136 bytes long.
a CWinThread object at $00000000074DFC00, 136 bytes long
Object dump complete.
The thread 'Win64 Thread' (0xea0) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x63c) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x13d4) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x15c8) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x1664) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x120c) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0xc78) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0xf6c) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x1408) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x11fc) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x1560) has exited with code 0 (0x0).
The thread 'MxsProxyGC' (0x1514) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x1074) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x10fc) has exited with code 0 (0x0).
The thread 'MxsProxyPump' (0x128c) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x166c) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x1558) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0xb34) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x131c) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0xb28) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x101c) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x1098) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x16ec) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x1744) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x16a0) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0xf0c) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x15dc) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x484) has exited with code 0 (0x0).
The thread 'Win64 Thread' (0x150c) has exited with code 0 (0x0).
The program '[3132] Real OCT and ODT.exe: Native' has exited with code 0 (0x0).

//MainFrm1.h start //////////////////////////////////////
class CMainFrame : public CFrameWnd
{
public:
	CMainFrame();

protected: 
	DECLARE_DYNAMIC(CMainFrame)

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMainFrame)
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
	//}}AFX_VIRTUAL

// Implementation
public:

	void ReOpen();
	virtual ~CMainFrame();
	int MotionControl;

//	CxImage *m_pMergingCanvas;

#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:  // control bar embedded members
	CStatusBar  m_wndStatusBar;
	CToolBar    m_wndToolBar;
	CReBar      m_wndReBar;
	CDialogBar  m_wndDlgBar;
	CChildView  m_wndView;

// Generated message map functions
//	protected:
public:

	afx_msg void OnDaqOctplaying();
	afx_msg BOOL MultiThreadMaking();

	static UINT DRAWThread(LPVOID pParam);
	static UINT DAQThread(LPVOID pParam);
	static UINT DSPThread(LPVOID pParam);
//	static UINT StopThread(LPVOID lpdwParam);

	static void Wait(DWORD);

	afx_msg void Messagebox_test(void);
	afx_msg void OnFilepath();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	int PIStageID;

	void OnBgBLACK(void);

	bool m_MergingCheck;
	afx_msg void OnEnChangeBrightness();
	afx_msg void OnEnChangeContrast();
	afx_msg void OnBnClickedFringebg();
};
//MainFrm1.h end////////////////////////////////////////////


//MainFrm1.cpp start //////////////////////////////////////
CWinThread *pDAQThread = NULL;
CWinThread *pDSPThread = NULL;
CWinThread *pDRAWThread = NULL;

//MultiThread variable
static bool volatile startFlag = false;
static bool volatile DAQThreadFlag, DSPThreadFlag, DRAWThreadFlag;

CEvent Event_DAQ, Event_DSP, Event_DRAW, Event_STOP;

static uInt16	*user_buff;
static Int8         *ImaqBuffers[NUM_RING_BUFFERS];   // acquisiton buffer

UINT CMainFrame::DAQThread(LPVOID pParam)
{
	HANDLE hProcess;		// Current process handle
	hProcess = GetCurrentProcess();
	//SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS);
	SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS);
	int i, j;

	CMainFrame *pIMAQError = (CMainFrame *)pIMAQError;
	CMainFrame *pDAQError = (CMainFrame *)pDAQError;
	int32       DAQerror=0;
	int			IMAQerror=0;
	char        errBuff[2048]={'\0'};

    int bufferIndex = 0;
	uInt32 currBufNum;
	void* bufAddr = NULL;

	while(startFlag == true)
	{
		while(DAQThreadFlag == true)
		{
			Event_DAQ.Lock();

				errChk(imgSessionExamineBuffer2 (Sid, bufferIndex, &currBufNum, &bufAddr));
				user_buff = (uInt16 *) bufAddr;
				// reinsert the buffer back in the ring
				errChk(imgSessionReleaseBuffer (Sid));

				// Now get next buffer
				bufferIndex ++;

				Event_DSP.PulseEvent();
		}
		DSPThreadFlag = false;
		DRAWThreadFlag = false;
	}

	TRACE("DAQ Thread End\n");
	return 0;

}

UINT CMainFrame::DSPThread(LPVOID pParam)
{
	BOOL err;
	float temp1, temp2;
	unsigned short bmpCount=0;

	while(startFlag==true)
	{
		while(DSPThreadFlag==true)
		{
			Event_DSP.Lock();

			if(iProgStatus == 8)  //OCT displaying
			{
				int i, j, k;

				Ipp32f *data1, *data3Re, *data3Im, *spectrumRe, *spectrumIm, *magnitude;

				#pragma omp parallel private(i, j, k, data1, temp1, temp2, spectrumRe, spectrumIm, data3Re, data3Im, magnitude)//, pOCTAscanSpec)
				{
					data1 = (float*)calloc(iCount, sizeof(float));
					spectrumRe = (float*)calloc(iCount, sizeof(float));
					spectrumIm = (float*)calloc(iCount, sizeof(float));
					data3Re = (float*)calloc(iCount, sizeof(float));
					data3Im = (float*)calloc(iCount, sizeof(float));
					magnitude = (float*)calloc(HeightPixel, sizeof(float));

					#pragma omp for
					for(i=0;i<XRange;i++) 
					{
						for (j=0; j<iCount-1; j++) //interpolation
						{
							temp1= *(user_buff + index[j]+i*iCount)-m_ibackground[index[j]]; 
							temp2= *(user_buff + index[j]+1+i*iCount)-m_ibackground[index[j]+1];
							data3Re[j]=temp1+(temp2-temp1)*k2LambdaRate[j];//(klambda[k]-lambda[index[k]])/(lambda[index[k]+1]-lambda[index[k]]);//*cosfDispersion[j];
							data3Im[j]=0;
						}
						data3Re[iCount-1] = *(user_buff + iCount-1+i*iCount)-m_ibackground[iCount-1];

						data3Im[iCount-1] = 0.0;

						ippsMul_32f_I(win, data3Re, iCount);

						ippsFFTFwd_CToC_32f(data3Re, data3Im, spectrumRe, spectrumIm, FFTspecification, NULL);

						ippsMagnitude_32f(spectrumRe, spectrumIm, magnitude, HeightPixel);//500*700 pixel

						ippsSub_32f(pOCTBackGround[i], magnitude, magnitude, HeightPixel);

						ippsFlip_32f_I(magnitude, HeightPixel);

						ippsThreshold_LTVal_32f_I(magnitude, HeightPixel, 1.0e-10, 0.0);
						ippsLog10_32f_A11(magnitude, magnitude, HeightPixel);
						ippsMulC_32f_I(10.0, magnitude, HeightPixel);

						ippsAddC_32f_I(dBrightness, magnitude, HeightPixel);//dBrightness
						ippsMulC_32f_I(dContrast, magnitude, HeightPixel);//dContrast

						ippsThreshold_LTValGTVal_32f_I(magnitude, HeightPixel, 0.0, 0.0, 255.0, 255.0);

						ippsCopy_32f(magnitude, pOCTAscanSpec[i], HeightPixel);
					}
					free(data1);
					free(spectrumRe);
					free(spectrumIm);
					free(data3Re);
					free(data3Im);
					free(magnitude);
				}
				ippsJoin_32f16s_D2L((const Ipp32f**) pOCTAscanSpec, XRange, HeightPixel, ipp_1d_16s);
				ippsConvert_16s32f_Sfs(ipp_1d_16s, ipp_1d_32f, XRange*HeightPixel, 0);
				ippsConvert_32f8u_Sfs(ipp_1d_32f, lpBmpOCT, XRange*HeightPixel, ippRndZero, 0);
			}

			Event_DRAW.PulseEvent();
/		}
		DRAWThreadFlag = false;
		DAQThreadFlag = false;
	}

	TRACE("DSP Thread End\n");
	return 0;

}

UINT CMainFrame::DRAWThread(LPVOID pParam) // ADC performance for OCT displaying
{

//	CChildView *pView = (CChildView *)pParam;

	int DrawTime = 1;

	int			IMAQerror=0;

	while(startFlag == true)
	{
		while(DRAWThreadFlag == true)
		{
			Event_DRAW.Lock();

			QueryPerformanceFrequency( &DRAWFrequency );
			QueryPerformanceCounter( &DRAWBeginTime ); 

//			pView->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);

			QueryPerformanceCounter( &DRAWEndtime );
			DRAWelapsed = DRAWEndtime.QuadPart- DRAWBeginTime.QuadPart; 
			timeDRAWResult = (double)DRAWelapsed / (double)DRAWFrequency.QuadPart*1000.0;

			Event_DAQ.PulseEvent();
		}
		DSPThreadFlag = false;
		DAQThreadFlag = false;
	}

	TRACE("DRAW Thread End\n");

	return 0;
}


BOOL CMainFrame::MultiThreadMaking()
{
		pDAQThread = AfxBeginThread(DAQThread, (LPVOID)this);
		pDSPThread = AfxBeginThread(DSPThread,(LPVOID)this);
		pDRAWThread = AfxBeginThread(DRAWThread,(LPVOID)this);

		Event_DAQ.PulseEvent();

		return 0;
}


void CMainFrame::OnDaqOctplaying()  //iProgStatus==8
{	
	if(iProgStatus == 1) 
	{
		m_wndDlgBar.SetDlgItemText(IDC_PLAY, "STOP"); 		// Set caption of button to "STOP"
		iProgStatus = 8;

		iBufferStatus = 0;

		// Allocate memory for bitmap 
		if(hDIB1 != NULL) hDIB1 = GlobalFree(hDIB1);
		hDIB1 = GlobalAlloc(GMEM_MOVEABLE, sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD) + XRange*HeightPixel);//(int)((iCount)/2.0));
		lpBmpOCT = (BYTE *)GlobalLock(hDIB1);

////////////////////////////////////////////////////////////////////////////////////////
			// Write BITMAPINFOHEADER
		lpDIBInfoOCT = (LPBITMAPINFOHEADER)lpBmpOCT;
		lpDIBInfoOCT->biSize = sizeof(BITMAPINFOHEADER);
		lpDIBInfoOCT->biWidth = XRange;
		lpDIBInfoOCT->biHeight = HeightPixel;//(int)((iCount)/2.0);//(int)((iCount - 1)/3.0); // Why divide it by 5
		lpDIBInfoOCT->biPlanes = 1;
		lpDIBInfoOCT->biBitCount = 8;
		lpDIBInfoOCT->biCompression = BI_RGB;
		lpDIBInfoOCT->biSizeImage = XRange*lpDIBInfoOCT->biHeight;
		lpDIBInfoOCT->biXPelsPerMeter = 0;
		lpDIBInfoOCT->biYPelsPerMeter = 0;
		lpDIBInfoOCT->biClrUsed = 256;
		lpDIBInfoOCT->biClrImportant = 0;
		// Write color table
		// Write Color table

		RGBQUAD *bmiColors;	
		bmiColors = (RGBQUAD *) (lpBmpOCT + sizeof(BITMAPINFOHEADER));
		unsigned int i;
		for(i=0;i<256;i++,bmiColors++)
		{
			bmiColors->rgbBlue = i;
			bmiColors->rgbGreen = i;
			bmiColors->rgbRed = i;
			bmiColors->rgbReserved = 0;
		}
		lpBmpOCT = lpBmpOCT + sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD);

		//***** Create Task for Frame grabber & DAQ board (3/7/2008)
		errChk(imgInterfaceOpen("img0", &Iid));
		errChk(imgSessionOpen(Iid, &Sid));

		//**** Set the ROI to obtain spectrum
		AcqWinWidth = iCount;
		AcqWinHeight = XRange;

		// Set the ROI to the size of the Canvas so that it will fit nicely
		errChk(imgSetAttribute2 (Sid, IMG_ATTR_ROI_WIDTH, AcqWinWidth));
		errChk(imgSetAttribute2 (Sid, IMG_ATTR_ROI_HEIGHT, AcqWinHeight));
		errChk(imgSetAttribute2 (Sid, IMG_ATTR_ROWPIXELS, AcqWinWidth));

		// create a buffer list with one element
		errChk(imgCreateBufList(NUM_RING_BUFFERS, &Bid));
		// compute the size of the required buffer
		errChk(imgGetAttribute (Sid, IMG_ATTR_BYTESPERPIXEL, &bytesPerPixel));
		bufSize = AcqWinWidth * AcqWinHeight * bytesPerPixel;

		for (int i = 0; i < NUM_RING_BUFFERS; i++)
		{
			errChk(imgCreateBuffer(Sid, FALSE, bufSize, (void**)&ImaqBuffers[i]));
			errChk(imgSetBufferElement2(Bid, i, IMG_BUFF_ADDRESS, ImaqBuffers[i]));
			errChk(imgSetBufferElement2(Bid, i, IMG_BUFF_SIZE, bufSize));
			bufCmd = (i == (NUM_RING_BUFFERS - 1)) ? IMG_CMD_LOOP : IMG_CMD_NEXT;
			errChk(imgSetBufferElement2(Bid, i, IMG_BUFF_COMMAND, bufCmd));
		}

		// lock down the buffers contained in the buffer list
		errChk(imgMemLock(Bid));

		// Tell the acquisition to use a line trigger, which should be derived from the IMG_SIGNAL_EXTERNAL.
		errChk(imgSessionLineTrigSource2(Sid, IMG_SIGNAL_EXTERNAL, 0, IMG_TRIG_POLAR_ACTIVEH, 0));

		// configure the session to use this buffer list
		errChk(imgSessionConfigure(Sid, Bid));

		// start the acquisition, asynchronous
		errChk(imgSessionAcquire(Sid, TRUE, NULL));

		if(startFlag == true)
			return;

		startFlag = true;
			
		DAQThreadFlag = true;
		DSPThreadFlag = true;
		DRAWThreadFlag=true;

		MultiThreadMaking();  //Make three threads

		return;

	}

	if(iProgStatus == 8) 
	{
		// Stop the threads
		startFlag = false;
		DAQThreadFlag = false;

		DWORD dwRetCode;
		DWORD dwExitCode = 0;

		dwRetCode = ::WaitForSingleObject(pDAQThread->m_hThread, 3000);
		if(dwRetCode == WAIT_OBJECT_0)
		{
		 TRACE("pDAQThread is terminated normally\n");
		}
		else if(dwRetCode == WAIT_TIMEOUT) 
		{
		 ::TerminateThread(pDAQThread->m_hThread, 0 );
		 TRACE("pDAQThread is terminated FORCELY!!!\n");
		}
		if(pDAQThread)
		{
		 GetExitCodeThread(pDAQThread->m_hThread, &dwExitCode);
		 TRACE("pDAQThread is terminated(code=%d)\n", dwExitCode);
//		 delete pThread;   // m_bAutoDelete = FALSE의 경우 스레드의 삭제를 잊지말자. 
		}

		dwRetCode = ::WaitForSingleObject(pDSPThread->m_hThread, 3000);
		if(dwRetCode == WAIT_OBJECT_0)
		{
		 TRACE("pDSPThread is terminated normally\n");
		}
		else if(dwRetCode == WAIT_TIMEOUT) 
		{
		 ::TerminateThread(pDSPThread->m_hThread, 0 );
		 TRACE("pDSPThread is terminated FORCELY!!!\n");
		}
		if(pDSPThread)
		{
		 GetExitCodeThread(pDSPThread->m_hThread, &dwExitCode);
		 TRACE("pDSPThread is terminated(code=%d)\n", dwExitCode);
//		 delete pThread;   // m_bAutoDelete = FALSE의 경우 스레드의 삭제를 잊지말자. 
		}

		dwRetCode = ::WaitForSingleObject(pDRAWThread->m_hThread, 3000);
		if(dwRetCode == WAIT_OBJECT_0)
		{
		 TRACE("pDRAWThread is terminated normally\n");
		}
		else if(dwRetCode == WAIT_TIMEOUT) 
		{
		 ::TerminateThread(pDRAWThread->m_hThread, 0 );
		 TRACE("pDRAWThread is terminated FORCELY!!!\n");
		}
		if(pDRAWThread)
		{
		 GetExitCodeThread(pDRAWThread->m_hThread, &dwExitCode);
		 TRACE("pDRAWThread is terminated(code=%d)\n", dwExitCode);
//		 delete pThread;   // m_bAutoDelete = FALSE의 경우 스레드의 삭제를 잊지말자. 
		}

		// stop the acquisition
		imgSessionAbort(Sid, NULL);

		// unlock the buffers in the buffer list
		if (Bid != 0)
			imgMemUnlock(Bid);

		// dispose of the buffers 
		for (int i = 0; i < NUM_RING_BUFFERS; i++)
			if (ImaqBuffers[i] != NULL)
				imgDisposeBuffer(ImaqBuffers[i]);

		// close this buffer list
		if (Bid != 0)
			imgDisposeBufList(Bid, FALSE);

		// Close the interface and the session
		if(Sid != 0)
			imgClose (Sid, TRUE);
		if(Iid != 0)
			imgClose (Iid, TRUE);

		// Reset the session variables.
		Sid = Bid = Iid = 0;

		iProgStatus = 1;
		iBufferStatus = 2;
		m_wndDlgBar.SetDlgItemText(IDC_PLAY, "PLAY"); 		// Set caption of button to "PLAY"

		return;
	}
	return;
}
//MainFrm1.cpp end

//ChildView1.cpp start
CChildView::CChildView()
{
	hDrawView = DrawDibOpen();
	hDrawView1 =DrawDibOpen();
	hDrawView2 =DrawDibOpen();
}

CChildView::~CChildView()
{
	DrawDibClose(hDrawView);
	DrawDibClose(hDrawView1);
	DrawDibClose(hDrawView2);
}

void CChildView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
//	CMemDC pDC(dc);

	int iXOffset1=10, iYOffset1=10, iXOffset2=10, iYOffset2=10;
	
	// TODO: Add your message handler code here

	BYTE *lpBmp;
	LPBITMAPINFOHEADER lpDIBInfo;
	int iXOffset=10, iYOffset=10;
	int iXWidth, iYHeight;
	double fPropotion;

	CRect cWndRect;
	GetWindowRect(cWndRect);

	POINT axis;
	axis.x = cWndRect.Width();
	axis.y = cWndRect.Height();

	if(iProgStatus == 8) { //OCT playing
		iXOffset = (int) (0.1*cWndRect.Width());
		fPropotion = 0.5*cWndRect.Width()/(lpDIBInfoOCT->biWidth);//0.7
		iXWidth = (int) (fPropotion*(lpDIBInfoOCT->biWidth));
		iYHeight =  (int) 0.3*(lpDIBInfoOCT->biHeight);

			fPropotion=1;

			if (0.8*axis.y*fPropotion < axis.x*0.8)
			{
				iYHeight = (int) (axis.y*0.8);
				iXWidth = (int) (fPropotion*iYHeight);			
			}
			else 
			{
				iXWidth = (int) (axis.x*0.8);
				iYHeight = (int) (iXWidth/fPropotion);
			}
			iXWidth = (int)(iXWidth/4.0*4);
			iYHeight=(int)(iYHeight/4.0*4);

		DrawDibDraw(hDrawView, dc.m_hDC, iXOffset, iYOffset, iXWidth, 
			iYHeight, lpDIBInfoOCT, lpBmpOCT, 0, 0, 
			lpDIBInfoOCT->biWidth, lpDIBInfoOCT->biHeight, DDF_ANIMATE);

		dc.TextOut(1024,200,performance1);
		dc.TextOut(1024,250,performance2);
		dc.TextOut(1024,300,performance3);
	}
	// Do not call CWnd::OnPaint() for painting messages
}

//ChildView1.cpp end //////////////////////////////////////










Is CMap derived class thread-safe?

$
0
0

I am writing a Visual C++ application, with a member variable CMap<int, int, int, int> m_MyMap;

In the application, there will be two threads, the first one will write to m_MyMap by calling m_MyMap.SetAt, and the second one will lookup the map by calling m_MyMap.Lookup. Is CMap dervied class thread-safe? Or do I need to do anything special to make sure it is thread-safe?

Thanks

Validate file name

$
0
0
Hi,

argv[0] should have one file name and I want to validate if it is correct or not, by this
	if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(argv[0]))
	{
		...

but I've got these

1>c:\app8\app8\app8.cpp(38): error C2065: 'INVALID_FILE_ATTRIBUTES' : undeclared identifier
1>c:\app8\app8\app8.cpp(38): error C3861: 'GetFileAttributes': identifier not found



Many Thanks & Best Regards, Hua Min


Visual Studio 2012 .exe fails in other computers

$
0
0
Hi i build an application that runs fine on my two computers with Visual studio 2012 installed .But when i try to run the .exe from Release folder on any other computer it fails to run.

Error : Program has stopped working.

I have already tried cleaning the whole solution and rebuilding again. I am sure i a copying all the files . I have also tried "Any CPU " build . 

Please help

Here is the event log :

    Log Name:      Application
    Source:        .NET Runtime
    Date:          8/19/2014 11:20:10 AM
    Event ID:      1026
    Task Category: None
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      WIN-E16CLTN23CM
    Description:
    Application: myRfid.exe
    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.IO.FileNotFoundException
    Stack:
       at myRfid.Form1.InitializeComponent()
       at myRfid.Form1..ctor()
       at myRfid.Program.Main()
    
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name=".NET Runtime" />
        <EventID Qualifiers="0">1026</EventID>
        <Level>2</Level>
        <Task>0</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2014-08-19T02:20:10.000000000Z" />
        <EventRecordID>1493</EventRecordID>
        <Channel>Application</Channel>
        <Computer>WIN-E16CLTN23CM</Computer>
        <Security />
      </System>
      <EventData>
        <Data>Application: myRfid.exe
    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.IO.FileNotFoundException
    Stack:
       at myRfid.Form1.InitializeComponent()
       at myRfid.Form1..ctor()
       at myRfid.Program.Main()
    </Data>
      </EventData>
    </Event>

Howto resize a CMFCRibbonPanel

$
0
0

In a ribbon, I have the following panel called 'Preset' which contains a gallery (CMFCRibbonGallery)

The default width of the gallery is automaticaly set to 309 pixels. At run time, I can dynamically expand the width of this gallery by using the CMFCRibbonGallery::SetRect(...), so I get the following result:

What should I do now to resize the 'Preset' panel ?

There is no similar function like 'CMFCRibbonPanel::SetRect(...)' for the panel and the RecalcLayout() doesn't fix anything.

Adding plugins to MFC SDI application

$
0
0

Hi,

I have a MFC SDI application developed in VC++ using Visual studio 2013.

Now I want to add plugins like menus,buttons to the existing SDI application.

My intention is that Plugins should add to the existing SDI application without rebuilding the SDI application.

Please guide me with some code samples and links on how I can do it.

Thanks in advance,

Alex

I NEED an Sample Code

$
0
0

I have to create a list control in my dialog based application and I did that. Now I want to make the list control as, "I will select a row (list) then that will be highlighted and I will right click on the another list to get the popup menu. This time, the first selected list will be lighten the highlighted color and the new one will be highlighted with the dotted lines as showed in the attached image and if I select any action from the popup menu then that should be done for the second selected list".

This image is take from the outlook mail list.

Is this possible in List control?

Kindly provide your valuable suggestions

AS im new to this pls send me an sample code

VS 14 CTP3: *fopen_s functions stuck when called at dll unload from a different thread

$
0
0

My code was working fine in the previous VS versions, but not in VS 14.

I have a logging in it's own thread. When I unload my dll, the logging thread would write some last notes, but it just stuck in the "_wfopen_s(&logfile, log_file.c_str(), L"a+, ccs=UTF-16LE")" function and never returns.

I have submitted this as a bug report at https://connect.microsoft.com/VisualStudio/Feedback
but I just got a reply to send them the dump file with the Microsoft Visual Studio 2013 Feedback Tool.

The problem with this that I have no dump file since my program stuck and not crashes, and that I can't even install this tool since it's incompatible with VS 14.

Viewing all 15302 articles
Browse latest View live


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