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

Posting messages between process with string data


How drag drop a button in vc++

$
0
0

Here i saw a code for c# and i convert it to vc++.But i tried it many way.i didn't get errors in this code.

but output is not get

private: System::Void toolStripButton1_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e)
{
this->DoDragDrop(Text, DragDropEffects::Copy);
// this->DoDragDrop(Text, DragDropEffects::Copy);
}
private: System::Void panel1_DragEnter(System::Object^  sender, System::Windows::Forms::DragEventArgs^  e) {
e->Effect = DragDropEffects::Copy;
/* if(e->Equals(DataFormats::Equals))
       {
e->Effect=DragDropEffects::Copy;
       }
else
   {
e->Effect=DragDropEffects::None;
   }*/
}
private: System::Void panel1_DragDrop(System::Object^  sender, System::Windows::Forms::DragEventArgs^  e)
{
ToolStripButton^ button = gcnew ToolStripButton();
                        if (button !=nullptr) {
                               if (button->Equals(toolStripButton1)) {
                              MessageBox::Show("Dragged and dropped Button 1");
   } 
}
}

which dataformats is used for button here........................................................ 



Problem creating COM Add-In Using Visual Studio 2013 Ultimate Edition in C++

$
0
0

I've created dozens of C++ COM Add-Ins using Visual Studio 2010. However, 2013 will not let me get passed the following step.  When I  right click in the Class View and select "Implement Interface ..."  the following occurs:

1.  First the Wizard shows up.   I select "Microsoft Add-In Designer<1.0>"

2.  After selecting _IDTExtensibility2 interface I select Finish and get the following error
"An error occurred while setting the error info."


3.  After clicking "OK"  the following error appears
"Error in OnFinish: Failed to return new Code Element.  Possibly syntax error.  New Element Name: _IDTExtensibility2"


Are we still able to create simple COM Add-Ins in C++ Using Visual Studio 2013?

SelectClipRgn fails on some zoom factor (VC++ MFC)

$
0
0

After doing CreatePolygonRgn and SelectClipRgn, I draw a vector long enough to cover the polygon area --- pDC->MoveTo(p1) & LineTo(p2).

The p1 & p2 are adjusted each time based on the current zoom factor of the screen. As I zoom in using the mouse wheel, at some point, a piece of the line is broken and displaced on a wrong spot... That is, I see two lines.  This happens at some high zoom factor, and if I zoom out again, my line is OK with the proper clipping based on my polygon.  

This only happens on lines close to vertical (but not exactly 90 degrees), and only on some high zoom-in situation. As I pan the picture, the broken line lengths change.

I am re-drawing the line every time I zoom or pan, executing the same piece of code that sets the clip rgn, draw, and disable the clip by pDC->SelectClipRgn().

Is this a graphic card issue?  This problem does not happen in PC SAFE MODE run...

Thank you 
Makoto

This is an image of broken lines:

http://screencast.com/t/47mPbq3u0



forget to delete an array in c++ program

$
0
0
now , i forget to delete some arrays in my program in win32 console application .
how to empty my memory leaks ?
i have deleted all my solutions .. so i couldn't back to my program to delete these arrays .
can any body help me please.

Access COM interface of C# Word Add-in from C++

$
0
0

I have a Word Add-in written in C++/ATL and want to access the COM interface of another add-in written in C#. The developer of the C# add-in has provided code that would do the job in C#, but I'm having trouble translating that to C++.

Here is the example provided (some variable names changed):

Object addinName = "FOO.BAR.POC.Listener";
Office.COMAddIn a = Globals.ThisAddIn.Application.COMAddIns.Item(ref addinName);           
var resultFromKnownInterface = ((global::FOO.BAR.Listener.IListener)a.Object).InitializeIdea("hello there!");

I believe that the C++ version sould include something like the following:

IDispatch *bApp = NULL;

_AtlModule.m_pGIT->GetInterfaceFromGlobal( dwCookie, L"FOO.BAR.POC.Listener", (PVOID*)&bApp );

But this produces an error:

Error2error C2664: 'IGlobalInterfaceTable::GetInterfaceFromGlobal' : cannot convert parameter 2 from 'const wchar_t [24]' to 'const IID 

I tried replacing parameter 2 with the GUID of the add-in, but that produced essentially the same error.

Any suggestions would be welcome. 

OleCreatePropertyFrame under Win8.1/10 is different to Win7 and below

$
0
0

I'm seeing an unknown error (80004005) in my application when I use this function to display property pages in Windows 8.1 or 10.

This worked in Windows 7 and XP.

My component(s) that contain the property page(s) are not normally registered with "regsvr32" as I create object instances directly (using custom factory code) but if I do register the .dll(s) I've developed it works as expected.  Problem is, I don't want to release projects where .dll(s) are registered.  That's why I wrote my own factory code.

Is there any workaround other than to register .dll(s)?

(Note: I've tested registering and unregistering the .dll(s) while the app is running, once it's registered it works and shows the pages even once unregistered, until the app is restarted, where it consistently fails again under the new OS's.)

Debug assertion failed (shortest path using Dijkstra's algorithm)

$
0
0

When debugging, I receive...

Debug Assertion Failed|

Program ...

File: f:\dd\vctools\crt_bld\self_x86\crt\src\output.c

Line: 2293

Expression: ((state == ST_NORMAL) || (state == ST_TYPE))

Here is the code.

// Code2A.h
#include <afxwin.h>
#include <math.h>
#define m 20
#define LinkRange 200

class CCode2A : public CFrameWnd
{
private:
typedef struct
{
int Wt,sd;
int via[10];
}LINK;
LINK e[m+1][m+1];
CRect rec[m+1];
CPoint home,end;
int sou,des;
int i,j,k,lFlag;
double alpha[m+1][m+1][m+1],x[m+1],y[m+1];
public:
CCode2A();
~CCode2A();
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT,CPoint);
void compute();
void computepath();
void drawpath();
DECLARE_MESSAGE_MAP()
};

class CMyWinApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};

CMyWinApp MyApplication;

BOOL CMyWinApp::InitInstance(void)
{
m_pMainWnd = new CCode2A;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

// Code2A.cpp
#include "a7.h"

BEGIN_MESSAGE_MAP(CCode2A,CFrameWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

CCode2A::CCode2A()
{
Create(0,L"Code2A: My skeleton Windows",WS_OVERLAPPEDWINDOW,CRect(0,0,1000,700));
}

CCode2A::~CCode2A()
{

}

void CCode2A::OnPaint()
{
CPaintDC ic(this);
CString s;
lFlag=0;
time_t seed=time(NULL);srand((unsigned)seed);
CPen drwrec(PS_SOLID,2,RGB(150,150,150));
home=CPoint(21,21);end=CPoint(699,499);
ic.Rectangle(20,20,800,500);
ic.SetTextColor(RGB(255,255,255));
ic.SetBkMode(TRANSPARENT);
ic.SelectObject(drwrec);
for(i=0;i<=m;i++)
{
x[i]=home.x+rand()%(end.x-home.x-20);
y[i]=home.y+rand()%(end.y-home.y-20);
rec[i]=CRect(x[i],y[i],x[i]+20,y[i]+20);
ic.FillSolidRect(rec[i],RGB(100,100,100));
s.Format(L"%d",i);
ic.TextOutW(x[i]+2,y[i]+2,s);
}
compute();
computepath();
}


void CCode2A::compute()
{
for(i=0;i<=m;i++)
{
e[i][i].Wt=0;
for(j=1;j<=m;j++)
{
if(sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))<=LinkRange)
e[i][j].Wt=e[j][i].Wt=1+rand()%9;
else
e[i][j].Wt=e[j][i].Wt=99;
}
}
for(i=0;i<=m;i++)
for(j=0;j<=m;j++)
{
e[i][j].sd=e[i][j].Wt;
for(k=0;k<=m;k++)
alpha[i][j][k]=99;
}

}

void CCode2A::computepath()
{
CClientDC dc(this);
CString r;
int mn,n;
for(i=0;i<=m;i++)
for(j=1;j<=m;j++)
for(k=0;k<=m;k++)
if(e[j][i].sd!=99||e[i][k].sd!=99||e[j][k].sd!=99)
if(e[j][i].sd+e[i][k].sd<e[j][k].sd)
{
n=1;
e[j][k].sd=e[j][i].sd+e[i][k].sd;
for(mn=1;mn<=m;mn++)
alpha[j][k][mn]=99;
for(mn=1;mn<=m;mn++)
if(alpha[j][i][m]!=99)
alpha[j][k][n++]=alpha[j][i][mn];
alpha[j][k][n++]=i;
for(mn=1;mn<=m;mn++)
if(alpha[i][k][m]!=99)
alpha[j][k][n++]=alpha[i][k][m];
}

dc.SetTextColor(RGB(170,170,170));
for(i=0;i<=m;i++)
for(j=0;j<=m;j++)
if(e[i][j].Wt!=99)
{
dc.MoveTo(x[i],y[i]);
dc.LineTo(x[j],y[j]);
r.Format(L"%d",e[i][j].Wt);
if(i!=j)
dc.TextOutW((x[i]+x[j])/2,(y[i]+y[j])/2,r);
}
}


void CCode2A::drawpath()
{
CClientDC dp(this);
CString ss;
//CRect rer;
//CBrush bru(RGB(230,230,230));
CPen drw(PS_SOLID,2,RGB(200,0,0));
//rer=CRect(20,20,800,500);
//dp.FillRect(&rer,&bru);
int r,p,q,w,k,u;
dp.SetTextColor(RGB(0,0,0));
//dp.SetBkColor(RGB(230,230,230));
p=150;q=120;
r=1; e[sou][des].via[r]=sou;
dp.TextOutW(p-100,510,L"Path:");
dp.TextOutW(p-100,550,L"Weight:");
ss.Format(L"%d",e[sou][des].via[r]);
dp.TextOutW(p,510,ss);

dp.SelectObject(drw);
w=sou;dp.MoveTo(x[w],y[w]);
for(k=0;k<=m;k++)
{
u=alpha[sou][des][k];
if(u!=99)
{
r++;e[sou][des].via[r]=u;
dp.LineTo(x[u],y[u]);
p+=60;
ss.Format(L"%d",e[sou][des].via[r]);
dp.TextOutW(p,510,ss);
q+=60;
ss.Format(L"%d",e[u][w].Wt);
dp.TextOutW(q,550,ss);
w=u;
}
}
if(e[des][w].sd!=99)
dp.LineTo(x[des],y[des]);
e[sou][des].via[r]=des;
ss.Format(L"%d",des);
p+=60;q+=60;
dp.TextOutW(p,510,ss);
ss.Format(L"%",e[des][w].sd);
dp.TextOutW(q,550,ss);
ss.Format(L"Total Weights: %d",e[sou][des].sd);
dp.TextOutW(q+60,540,ss);
}

void CCode2A::OnLButtonDown(UINT nFlags,CPoint pt)
{
for(int i=1;i<=m;i++)
if(rec[i].PtInRect(pt))
{
lFlag++;
if(lFlag==1)
sou=i; //source
if(lFlag==2)
des=i; //destination
if(lFlag==2)
{
OnPaint();drawpath();
lFlag=0;
}
}
}

how to solve it???


X64 inline assembly in Visual Studio 2015?

$
0
0
Will Visual Studio 2015 finally have X64 inline assembly like most of the other major compilers do? Having to still do workarounds when other compilers have had inlining for years does not help it look modern.

Native WiFi: Simulating WLAN Reason Codes

$
0
0

Hello everyone!

I am developing a software that pinpoints problems in WLAN connectivity using the Native WiFi API. I am trying to simulate scenarios for my code to identify problems using WLAN Reason Codes (https://msdn.microsoft.com/en-us/library/windows/desktop/ms707394%28v=vs.85%29.aspx).

I can connect to a WPA2-PSK network and I am using the Notification Callback to get the WLAN Reason Codes. I deliberately changed my network security key to find out if the notification callback can see that the reason for not being able to connect is a PSK mismatch. However, the reason that was identified is that the "Dynamic Key Exchange did not succeed within the configured time." This reason and the PSK mismatch are related, but I want to see that the Notification Callback actually identifies the PSK mismatch (WLAN_REASON_CODE_MSMSEC_PSK_MISMATCH_SUSPECTED). 

Is this possible using the Native WiFi API? If yes, how can I do it?

Thank you!!!

Can't change tooltip coordinates relatively to mouse (MFC).

$
0
0

Hi, i am trying to achieve that my Listcontrol will display tooltip for every cell. But i need it to be displayed

a little bit right to cursor. But it won't work, When i'am using TTF_TRACK tip doesnt even show up. I've tried

many variations with sendmessage and other but it still won't work. How can i resolve that?

void CListCtrl_OwnToolTipCtrl::OnMouseMove(UINT nFlags, CPoint point)
{


	//SendMessage(hTool, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
	//MessageBox(text,NULL,MB_OK);


	CPoint pt(GetMessagePos());
	ScreenToClient(&pt);


	// Find the subitem
	LVHITTESTINFO hitinfo = {0};
	hitinfo.flags = nFlags;
	hitinfo.pt = pt;
	SubItemHitTest(&hitinfo);


	if (m_LastToolTipCol!=hitinfo.iSubItem || m_LastToolTipRow!=hitinfo.iItem)
	{
		// Mouse moved over a new cell
		m_LastToolTipCol = hitinfo.iSubItem;
		m_LastToolTipRow = hitinfo.iItem;

		// Remove the old tooltip (if available)
		if (m_OwnToolTipCtrl.GetToolCount()>0)
		{
			m_OwnToolTipCtrl.DelTool(this);
			m_OwnToolTipCtrl.Activate(FALSE);
		}

		// Add the new tooltip (if available)
		if (m_LastToolTipRow!=-1 && m_LastToolTipRow!=-1)
		{

			// Not using CToolTipCtrl::AddTool() because it redirects the messages to CListCtrl parent
			TOOLINFO ti = {0};
			ti.cbSize = sizeof(TOOLINFO);
			//ti.uFlags = TTF_IDISHWND | TTF_TRANSPARENT | TTF_ABSOLUTE | TTF_TRACK;	// Indicate that uId is handle to a control
			ti.uFlags =   TTF_IDISHWND | TTF_TRANSPARENT;
			ti.uId = (UINT)m_hWnd;	// Handle to the control
			ti.hwnd = m_hWnd;			// Handle to window to receive the tooltip-messages
			//ti.rect = rcClient;
			ti.hinst = AfxGetInstanceHandle();
			ti.lpszText = LPSTR_TEXTCALLBACK;
			m_OwnToolTipCtrl.SetToolInfo(&ti);

			m_OwnToolTipCtrl.AddTool(GetDlgItem(IDC_LIST1),LPSTR_TEXTCALLBACK);
			m_OwnToolTipCtrl.SendMessage(TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
			//m_OwnToolTipCtrl.SendMessage(TTM_TRACKACTIVATE, true, (LPARAM)&ti);

			m_OwnToolTipCtrl.SendMessage(TTM_SETDELAYTIME, TTDT_INITIAL, 500);
			m_OwnToolTipCtrl.SendMessage(TTM_SETDELAYTIME, TTDT_AUTOPOP, 5000);
			//m_OwnToolTipCtrl.SetToolRect(m_hWnd, )
	        //CPoint vt(GetMessagePos());

			//m_OwnToolTipCtrl.SendMessage(TTM_TRACKPOSITION, 0, (LPARAM)MAKELPARAM(pt.x, pt.y+10 ));
			//m_OwnToolTipCtrl.SendMessage(TTM_TRACKACTIVATE, true, (LPARAM)&ti);


			m_OwnToolTipCtrl.Activate(TRUE);

			//Multiline
			m_OwnToolTipCtrl.SetMaxTipWidth(256);
			//m_OwnToolTipCtrl.SetMaxTipWidth(SHRT_MAX);
		}
	}

	CListCtrl::OnMouseMove(nFlags, point);

}


I attempt to develop the Dialog-Based Bluetooth Communication Program.

$
0
0

I want to develop the program that make a PC communicate with another PC or AVR via Bluetooth.

Most examples I found in MS and several web are Win32 console program and suggest how to make socket just like

Socket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);

But I'm more familiar to dialog-based programming using MFC.

Is it possible to use CSocket or CAsyncSocket class for the bluetooth communication?

Visual Studio 2013. Program cannot find an entry for __cxa_throw_bad_array_new_length method in libstdc++-6.dll when starting from .exe file

$
0
0

I am doing a program in C++ in Visual Studio 2013 IDE. The program uses Qt5 and openGL in Qt5.

Everything works when I am building and starting program in IDE (both Debug and Release modes).
But when I am trying to run the program by double clicking the generated .exe file, the following error occurs:

Cannot find the entry point for the procedure
    __cxa_throw_bad_array_new_length in library libstdc++-6.dll

Do you have any clues what I may doing wrong?

Thanks for any comments,

Adam



How to handle ALT+TAB while in full screen

$
0
0

I have an application that can become full screen (through a DXGI swap chain). I handle the WM_KEYDOWN event to watch for Escape key presses to exit full screen. That works ok. But when I press ALT+TAB while in full screen, I get some visual artifacts and the application seems to get into a limbo state where it isn't really full screen anymore but not windowed either.

How can I handle ATL+TAB while in full screen to properly exit full screen?

Microsoft Visual C++ Redistributables

$
0
0

I am basically a VB6 Programmer also using Access.  I found running in the background the following

NAME                                                                                           SIZE (MB)   VERSION

Microsoft Visual C++ 2005 Redistributable                                      300.00     8.0.61001    
Microsoft Visual C++ 2005 Redistributable (x64)                             620.00     8.0.59192   
Microsoft Visual C++ 2005 Redistributable (x64)                             572.00     8.0.56100   
Microsoft Visual C++ 2005 Redistributable (x64) - KB2467175         580.00     8.0.51011   
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.17         755.00     9.0.30729   
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161     700.00     9.0.30729.6161   
Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.17         596.00     9.0.30729   
Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161     600.00     9.0.30729.6161   
Microsoft Visual C++ 2010 x64  Redistributable - 10.0.40219              13.80    10.0.40219      

Microsoft Visual C++ 2010 x86  Redistributable - 10.0.40219             11.10     10.0.40219

I also have loaded

  
Microsoft Visual   Studio 6.0 Pro Edition

which I believe I need for my VB6.

   

Do I need these?  Can I delete these.

Thanks


Debug assertion failed (shortest path using Floyd-Warshall's algorithm)

$
0
0

When debugging, I receive...

Debug Assertion Failed|

Program ...

File: f:\dd\vctools\crt_bld\self_x86\crt\src\output.c

Line: 2293

Expression: ((state == ST_NORMAL) || (state == ST_TYPE))

Here is the code.

// Code2A.h
#include <afxwin.h>
#include <math.h>
#define m 20
#define LinkRange 200

class CCode2A : public CFrameWnd
{
private:
typedef struct
{
int Wt,sd;
int via[10];
}LINK;
LINK e[m+1][m+1];
CRect rec[m+1];
CPoint home,end;
int sou,des;
int i,j,k,lFlag;
double alpha[m+1][m+1][m+1],x[m+1],y[m+1];
public:
CCode2A();
~CCode2A();
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT,CPoint);
void compute();
void computepath();
void drawpath();
DECLARE_MESSAGE_MAP()
};

class CMyWinApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};

CMyWinApp MyApplication;

BOOL CMyWinApp::InitInstance(void)
{
m_pMainWnd = new CCode2A;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

// Code2A.cpp
#include "a7.h"

BEGIN_MESSAGE_MAP(CCode2A,CFrameWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

CCode2A::CCode2A()
{
Create(0,L"Code2A: My skeleton Windows",WS_OVERLAPPEDWINDOW,CRect(0,0,1000,700));
}

CCode2A::~CCode2A()
{

}

void CCode2A::OnPaint()
{
CPaintDC ic(this);
CString s;
lFlag=0;
time_t seed=time(NULL);srand((unsigned)seed);
CPen drwrec(PS_SOLID,2,RGB(150,150,150));
home=CPoint(21,21);end=CPoint(699,499);
ic.Rectangle(20,20,800,500);
ic.SetTextColor(RGB(255,255,255));
ic.SetBkMode(TRANSPARENT);
ic.SelectObject(drwrec);
for(i=0;i<=m;i++)
{
x[i]=home.x+rand()%(end.x-home.x-20);
y[i]=home.y+rand()%(end.y-home.y-20);
rec[i]=CRect(x[i],y[i],x[i]+20,y[i]+20);
ic.FillSolidRect(rec[i],RGB(100,100,100));
s.Format(L"%d",i);
ic.TextOutW(x[i]+2,y[i]+2,s);
}
compute();
computepath();
}


void CCode2A::compute()
{
for(i=0;i<=m;i++)
{
e[i][i].Wt=0;
for(j=1;j<=m;j++)
{
if(sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))<=LinkRange)
e[i][j].Wt=e[j][i].Wt=1+rand()%9;
else
e[i][j].Wt=e[j][i].Wt=99;
}
}
for(i=0;i<=m;i++)
for(j=0;j<=m;j++)
{
e[i][j].sd=e[i][j].Wt;
for(k=0;k<=m;k++)
alpha[i][j][k]=99;
}

}

void CCode2A::computepath()
{
CClientDC dc(this);
CString r;
int mn,n;
for(i=0;i<=m;i++)
for(j=1;j<=m;j++)
for(k=0;k<=m;k++)
if(e[j][i].sd!=99||e[i][k].sd!=99||e[j][k].sd!=99)
if(e[j][i].sd+e[i][k].sd<e[j][k].sd)
{
n=1;
e[j][k].sd=e[j][i].sd+e[i][k].sd;
for(mn=1;mn<=m;mn++)
alpha[j][k][mn]=99;
for(mn=1;mn<=m;mn++)
if(alpha[j][i][m]!=99)
alpha[j][k][n++]=alpha[j][i][mn];
alpha[j][k][n++]=i;
for(mn=1;mn<=m;mn++)
if(alpha[i][k][m]!=99)
alpha[j][k][n++]=alpha[i][k][m];
}

dc.SetTextColor(RGB(170,170,170));
for(i=0;i<=m;i++)
for(j=0;j<=m;j++)
if(e[i][j].Wt!=99)
{
dc.MoveTo(x[i],y[i]);
dc.LineTo(x[j],y[j]);
r.Format(L"%d",e[i][j].Wt);
if(i!=j)
dc.TextOutW((x[i]+x[j])/2,(y[i]+y[j])/2,r);
}
}


void CCode2A::drawpath()
{
CClientDC dp(this);
CString ss;
//CRect rer;
//CBrush bru(RGB(230,230,230));
CPen drw(PS_SOLID,2,RGB(200,0,0));
//rer=CRect(20,20,800,500);
//dp.FillRect(&rer,&bru);
int r,p,q,w,k,u;
dp.SetTextColor(RGB(0,0,0));
//dp.SetBkColor(RGB(230,230,230));
p=150;q=120;
r=1; e[sou][des].via[r]=sou;
dp.TextOutW(p-100,510,L"Path:");
dp.TextOutW(p-100,550,L"Weight:");
ss.Format(L"%d",e[sou][des].via[r]);
dp.TextOutW(p,510,ss);

dp.SelectObject(drw);
w=sou;dp.MoveTo(x[w],y[w]);
for(k=0;k<=m;k++)
{
u=alpha[sou][des][k];
if(u!=99)
{
r++;e[sou][des].via[r]=u;
dp.LineTo(x[u],y[u]);
p+=60;
ss.Format(L"%d",e[sou][des].via[r]);
dp.TextOutW(p,510,ss);
q+=60;
ss.Format(L"%d",e[u][w].Wt);
dp.TextOutW(q,550,ss);
w=u;
}
}
if(e[des][w].sd!=99)
dp.LineTo(x[des],y[des]);
e[sou][des].via[r]=des;
ss.Format(L"%d",des);
p+=60;q+=60;
dp.TextOutW(p,510,ss);
ss.Format(L"%",e[des][w].sd);
dp.TextOutW(q,550,ss);
ss.Format(L"Total Weights: %d",e[sou][des].sd);
dp.TextOutW(q+60,540,ss);
}

void CCode2A::OnLButtonDown(UINT nFlags,CPoint pt)
{
for(int i=1;i<=m;i++)
if(rec[i].PtInRect(pt))
{
lFlag++;
if(lFlag==1)
sou=i; //source
if(lFlag==2)
des=i; //destination
if(lFlag==2)
{
OnPaint();drawpath();
lFlag=0;
}
}
}

how to solve it???


C++ CLI backgroundworker not going to complete

$
0
0

Hello everyone, so my code is pretty straight forward i push a button and it runs backgroundworker. The code inside backgroundworker has a while loop that will run until it is broken. After i break it it just stay "there" does not do go to backgroundworker completed. This is  the code: (i found the code inside backgroundworker from another site, sorry cant remember)  So yeah after i press enter it breaks the while loop but like i said it never goes to backgroundworker completed, what do i have to do to tell the application that it has finished?

//=====================================================
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  backgroundWorker1->RunWorkerAsync(1);
 }

//=====================================================

 private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
  double startTime = GetTickCount();
  int i = 0;
  while (true)
  {
   double currentTime = GetTickCount() - startTime;

   if (currentTime >= 3000) //3 seconds.
   {
    std::cout << i << ":) ";
    updateThingsHere();
    i = i + 1;
    //Reset the timer.
    startTime = GetTickCount();
   }

   //Run other code here while not updating.

   char key = ' ';

   if (_kbhit())
    key = _getch();

   if (key == 13)
    break; //Quit the while loop


   else if (key != ' ')
   {
    key = ' ';
   }
  }
 }


//=========================================================

private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^  sender, System::ComponentModel::RunWorkerCompletedEventArgs^  e) {
 MessageBox::Show("Work completed!!");
 std::cout << "DONE/FINISHED" << std::endl;
}


//=========================================================

   void updateThingsHere(){
    std::cout << "DOING THINGS" << std::endl;
   }

Fixing C++ macros

$
0
0

I'm having a bit of trouble with the macro's $(VCInstallDir) and $(WindowsSdkDir).

I can hack the .props file in %AppData%\Local\Microsoft\MSBuild\v4.0 and get the compiler to work for both 32 bit and 64 bit by putting the fully qualified paths in but seem to have trouble getting the above macro's to work in all scenarios.

Is there a reference somewhere how these macro's obtain their values or does anyone have pointers on changing the value the environment uses?

Also a related question, I notice the 64 bit executable directory is listed as $(WindowsSdkDir)\bin\x64 but when I use the fully qualified path in Visual Studio I get an error that it can't run rc.exe.  Changing the path to the equivalent of $(WindowsSdkDir)\bin seems to work.  Should I be using the x64 directory and if so, how do I get the programs to actually run?  I've been able to create make files for both x64 and x86 that use the bin\x64 and bin  directories just fine.


Larry Charlton

Breaking Change in Visual Studio 2015 RC

$
0
0

Hello,

As we work to migrate our code to build with Visual Studio 2015, we are stuck with a linking error - LNK2019 unresolved symbol.

The page - https://msdn.microsoft.com/en-us/library/bb531344(v=vs.140).aspx mentions about Template resolution. It mentions about invalid template instantiations, that with VS 2015, that, SFINAE requires the compiler to instantiate the specialization of a class template.

With the example provided in the same section, I did see the mentioned compiler error, which is as per expectation. However, to fix the compiler error, it asks to move the definitions of structures B and D to the beginning of the code. Unfortunately, I am still not able to build the code snippet, as I get a linking error -

error LNK2019: unresolved external symbol "public: __thiscall S<struct D>::S<struct D>(struct S<struct D> const &)" (??0?$S@UD@@@@QAE@ABU0@@Z) referenced in function "void __cdecl f1(void)" (?f1@@YAXXZ)
1>c:\users\rupsharma\documents\visual studio 2015\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe : fatal error LNK1120: 1 unresolved externals

Here is how my cpp file looks like after the fix:

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <type_traits>

struct B
{
};

struct D : public B
{
};


template<typename T>
struct S
{
	S() = default;
	S(const S&);
	S(S&&);

	template<typename U, typename = typename std::enable_if<std::is_base_of<T, U>::value>::type>
	S(S<U>&&);
};

struct D;

void f1()
{
	S<D> s1;
	S<D> s2(s1);
}


void f2()
{
	S<D> s1;
	S<D> s2(s1);
}
int _tmain(int argc, _TCHAR* argv[])
{
	f2();
	return 0;
}

It seems to be a bug to me, which has been troubling us, while trying to migrate our project to VS 2015 RC. It would be great if you can check on this.

Thanks,

Rupali


 

How to display document in popup when iconic?

$
0
0
I have a MFC MDI app where a user opens and operates on many files at a time. Lots of times they minimize a lot of "documents" and its very hard to determine which is which document by the minimize view (caption bar) so what I would like to do is if the document is iconic popup a small windows and display the document, if they click the restore/maximize or the popup the document is restored. Any one know of any code, example to do this?

Thanks
Viewing all 15302 articles
Browse latest View live


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