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

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




I need my executable to run in all Windows computers

$
0
0

Hi!

I need an executable for my program that could run in any Windows computer despite the fact that it doesn't have Visual Studio installed. I have been reading that I need to run my program in the "Release" mode instead of "Debug". I run my program in the "Debug" mode and it runs perfectly but if I run it as a release, I get the following errors:

1>libcmt.lib(_file.obj) : error LNK2005: ___iob_func already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(_file.obj) : error LNK2005: __lock_file already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(_file.obj) : error LNK2005: __unlock_file already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
1>libcmt.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
1>libcmt.lib(atox.obj) : error LNK2005: _atoi already defined in MSVCRT.lib(MSVCR100.dll)
1>libcmt.lib(isctype.obj) : error LNK2005: __isctype already defined in MSVCRT.lib(MSVCR100.dll)

1>C:\Users\xx\Desktop\Program\RCM Program\RCM\Release\RCM.exe : fatal error LNK1169: one or more multiply defined symbols found

I have also read that that in order for the program to run in all computers I have to change the properties of the "Runtime Library" to Multi-threaded(/MT). When I do this I get an error that says that I cannot select this option when using "Common Language Runtime Support" or "Pure MSIL Common Language Runtime Support" which are the ones that my program uses. 

I also do not know how to make my input and output files paths generic. I have tried the path ".\\Archive.txt" but it looks for the file based on where the Visual Studio project is created, not with respect to the executable.

Anyways, I know I am all over the place but I just wanted to explain what I have read and tried to get it to work. But to sum up, my questions are: What is the easiest way to make my program run in all windows computers taking into account that it uses dll files? What path should I use for my input and output files?

Thank you so much for your help!

Unable to build C/++ 64 Bit Projekt with Visual Studio 2010: TRK0002 ... The handle is invalid

$
0
0

I have a solution containing a C/C++Projekt to build a C DLL. Within the project I have several build configurations: release and debug for 32 bit and release and debug for 64 bit. The compiles for the 32 environment are running fine, but when I start the build for 64 bit, I get the following message:

TRACKER : error TRK0002: Failed to execute command: ""C:\devtools\Microsoft Visual Studio 10.0\VC\bin\amd64\CL.exe" @c:\temp\c2724e05c261463e862bf366db3a1a69.rsp". Das Handle ist ungültig.

The project has been converted from Visual Studio 2008 so maybe this causes the problem. A 64 bit build with VS 2008 works fine.

On my PC I am working with Windows 7 Ultimate 64 Bit.

Martin Herbst
Delta Software Technology GmbH

Appearance of tooltips defined with CMFCRibbonGallery::SetItemToolTip()

$
0
0

I use

CMFCRibbonGallery::SetItemToolTip();

to set tool tips on gallery items in drop-down galleries.

Their appearance, however, is very iffy.   They don't always get drawn properly, for example in the top half of the attached image.   A bit of muse wiggling (off and back onto the gallery item) can often fix this, but it's irritating to have to do it.

Is there a work-around?

[I'm using VS 2013 community, and update 5 has not fixed it.]

Dave

Incorrect and correct tooltip appearance


David Webber Author of Mozart music notation software http://www.mozart.co.uk

Showing/hiding context caregories in a CMFCRibbonBar

$
0
0

I'm trying to develop code which is completely analogous to the behaviour of Microsoft Word: when the caret goes into a table cell, 'context categories' appear on the ribbon, which have all the table-editing commands.

In my case when the caret goes into a certain region of my CView-derived window, I want the context category to appear, and when it leaves, I want it to disappear.

At the moment I'm achieving this by posting my main frame a message when the caret's position changes in the relevant way, which essentially results in the following code in my CMFCRibbonBar-derived class being called

void CMyRibbonBar::rbConfigure(  BOOL bShowTablature  )
{
    CMFCRibbonCategory *pCategoryTablature = GetCategory( CAT_TABLATURE );
    CMFCRibbonCategory *pCategoryHome      = GetCategory( CAT_HOME );

    if( !bShowTablature )
    {
        // Hiding the category:
        // Ensure it is not active.

        if( pCategoryTablature && pCategoryTablature->IsVisible() )
        {
             if( pCategoryTablature->IsActive() )
				SetActiveCategory( pCategoryHome );
         }
     }

    ShowContextCategories( ID_CONTEXTTABLATURE, bShowTablature );
    Invalidate( );
    UpdateWindow();

    return;
}

It works except for two things:

1. There is text on the caption bar when the category is showing.  In MS Word it brackets two context categories; in my case only one:

context category tab and text on caption bar

When I hide the 'Tablature' category the caption bar is nor redrawn and so the 'Tablature tools' text remains and only disappears if I click on another tab.   Is there an easy way to ensure it goes?

2. The category tab itself comes and goes when I move the caret within the view window and when I switch between views - posting the user-message at appropriate points seems to do the trick.  But I cannot get it to work when opening an existing file (which has remembered its caret position) with the caret in a place where I need the context categories open, even though the message is being posted, and my function is being called.

Is there a better place to call it from?
(At the moment I'm considering checking the active view and resetting which categories are visible in the OnIdle() processing, but the correlation between calls to  ShowContextCategories() and actual visibility of them doesn't seem perfect, so I am not sure it would work!)  

Dave


David Webber Author of Mozart music notation software http://www.mozart.co.uk

Disk Partition

$
0
0
Hi all. I want to get all the disk partitions like C,D,F,.... and display it in some control (like list control). I am  using MFC application. I know I want to use GetLogicalDrives(). That is my only clue. Can someone pls help me on this? Any sample code would be helpful.

Assertion Failed

$
0
0

Hi..Yesterday I started getting this popup whenever  i tried opening a window in IE.  The only change to the system was 2 automatic downloads yesterday morning of Visual C++ 2013. I have no idea what that is,what it does or how to use it. Since the automatic downloads occurred this is the message I get when attempting to open a new window.

Assertion Failed

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Assertion failed!

Program: ...
File: d:\sunita\download\jsoncpp-src-0.5...\json_value.cpp
Line: 679

Expression: type_ == stringValue

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts

(Press Retry to debug the application - JIT must be enabled)
---------------------------
Abort   Retry   Ignore   
---------------------------

Convert UTC to local time using SystemTimeToTzSpecificLocalTime?

$
0
0

I have an epoc UTC time 1432743742 that represents Wed, 27 May 2015 16:22:22.

(See http://www.epochconverter.com/)

This time is actually 27/05/2015, 17:22:22 GMT+1:00 DST

I know that the timezone in question is GMT Standard Timeso I want to convert the epoc UTC time to the local time based on the timezone.

I believe that this function allows me to do it: SystemTimeToTzSpecificLocalTime.

If so, how can I use this function to convert an epoc UTC time to local time based on the timezone name?


Where to save user data?

$
0
0

Hi,

I need to save user information (name, password, results etc) but where in the file system should I save this file? I'm using C++ and MFC.

Any help appreciated, thanks.

Paul

DAO to ACEDAO upgrade in Visual C++ 6.0

$
0
0

Hi,

I'm new to Visual C++ and I have to modify an existing DLL built in VC++ 6.0.

It is using access 97 as its back end. I need to modify this to work with Access 2010.

I know that I have to add reference to acedao dll instead of dbdao.

Could anyone tell me the process for adding reference in Visual C++ 6.0?

Thanks

Jithesh

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

How to Update TreeCtrl in VC++ MFC ?

$
0
0

How to Update Particular Node Text as BOLD or COLOR in runtime.

for example ,

i have 5 nodes in a tree (all nodes are same color assume black ). named as,

NODE 1

NODE2

NODE 3

NODE 4

NODE 5

now i want to change the node 3 color to another color (black to red). and also put BOLD Text for NODE 4 like

(NODE 4 to NODE 4 ) under the ButtonClick (runtime)

Is this possible in VC++ MFC?

kindly Help me..

Thanks.

CListCtrl hittest always returns -1

$
0
0

I've got list control with report style and i need to copy some text from ItemData, but when i'am trying to make hittest it always returns -1

void Cmfc_test123Dlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	// TODO: Add your control notification handler code here
	*pResult = 0;
	CPoint pt(GetMessagePos());
	ScreenToClient(&pt);
	//UINT uFlags = LVHT_ONITEM;
	// Find the subitem
	LVHITTESTINFO hitinfo = {0};
	//hitinfo.flags = nFlags;
	hitinfo.pt = pt;
	int N = m_ctrlList.HitTest(pt, NULL);
	//int nRow = 0, nCol = 0;
	//int nInt = m_ctrlList.HitTest(pt, NULL);
	CString sMsg;
	sMsg.Format("%d",N);
	MessageBox(sMsg, NULL, MB_OK);
	//m_ctrlList.


}


IEnumWbemClassObject::Next method not working

$
0
0

i am trying to vendor specifc attribute from this WMI class MSStorageDriver_FailurePredictData(HDD SMART information). Here is the used code :

IEnumWbemClassObject* pEnumerator = NULL;
    hres = pSvc->ExecQuery( L"WQL", L"SELECT * FROM MSStorageDriver_FailurePredictData",
    WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);

    IWbemClassObject *pclsObj = NULL;
    ULONG uReturn = 0;
      while (pEnumerator)
   {
    HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
            //**I am getting an issue here the method Next() returns hr=-2147217405 **

    if(0 == uReturn || FAILED(hr))
      break;
         //do smoething
     }

i need to know why Next() is not working properly.

Migrating C++ ATL Executable application from VS2003 to VS2013

$
0
0

I am migrating my C++ ATL Executable application from VS2003 to VS2013.

In VS 2003

class CExeModule : public CComModule

In VS2013 (its been changed to)

class CExeModule : public ATL::CAtlExeModuleT< CExeModule >

I have successfully migrated the project, during compilation i am facing a issue

error C2664: 'ATL::CHandle::CHandle(HANDLE) throw()' : cannot convert argument 1 from 'bool' to 'ATL::CHandle &'

I don't get this error if i comment the following code 

_AtlModule.WinMain(nShowCmd);

Can someone help here to solve this error ?

Additional info

C:\Program Files\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlbase.h(3628): error C2664: 'ATL::CHandle::CHandle(HANDLE) throw()' : cannot convert argument 1 from 'bool' to 'ATL::CHandle &'
C:\Program Files\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlbase.h(3608) : while compiling class template member function 'HRESULT ATL::CAtlExeModuleT<CExeModule>::PreMessageLoop(int) throw()'
C:\Program Files\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlbase.h(3695) : see reference to function template instantiation 'HRESULT ATL::CAtlExeModuleT<CExeModule>::PreMessageLoop(int) throw()' being compiled

stdafx.h(107) : see reference to class template instantiation 'ATL::CAtlExeModuleT<CExeModule>' being compiled


Game programming

$
0
0

Hello. I'm new in game programming. So my questions are:

1. Which language I should choose to write source code (C# or C++ or may be others)?

2. Which graphic technology I should use (DirectX or OpenGL)?

3. Can I write for Window 7 or 8 with XNA game studio?

How to declare C# dll globally inside C++/CLI wrapper

$
0
0

I have created C++/CLI wrapper for calling C# dll methods and events.I have referenced C# dll in the C++/CLI wrapper project.I have called connect1 method which consists of colorinitialize() and colorclientconnect() both have to be called from C# dll.The following code i have used for calling C# dll with in C++/CLI wrapper.

NativeInterface.h

extern "C"{

   __declspec(dllexport) const char*  Connect1(char* str, int port);
    __declspec(dllexport)  const char*  Test(char* str, int port);
    };

SampleWrapper.cpp (C++/CLI wrapper)

#include "NativeInterface.h"
namespace Wrapper
{
#ifdef __cplusplus
extern "C"
{
#endif

            __declspec(dllexport)  const char*  Test(char* str, int port)
            {

                KinectV2Server::KinectV2 c1;

                c1.GetBytes();
                return str;
            }

            //String tmp;

            __declspec(dllexport)  const char*  Connect1(char* str, int port)
            {
                  KinectV2Server::KinectV2 c1;

                c1.ColorInitialize();
                c1.ColorClientConnect(gcnew System::String(str));


                return  str;
            }

        #ifdef __cplusplus
}
#endif
}

After that i will call this C++/CLI wrapper in another C++ application like this,

C++ application:

#include "SampleCPlusApps.h"
#include <math.h>
#include "Time.h"
#include "NativeInterface.h"

SampleCPlusApps::SampleCPlusApps(void)
{
    float smoothing = 0.7f;  //0.25f        // [0..1], lower values closer to raw data
    float correction = 0.3f; //0.25f        // [0..1], lower values slower to correct towards the raw data
    float prediction = 1.00f;  //0.25f       // [0..n], the number of frames to predict into the future
    float jitterRadius =  1.0f; // 1.03f;     // The radius in meters for jitter reduction
    float maxDeviationRadius = 1.0f;; //0.05f;// The maximum radius in meters that filtered positions are allowed to deviate from raw data

    fde.Init(smoothing, correction, prediction, jitterRadius, maxDeviationRadius);
    //initialization();

    //const char* test1;
    //test1= ("Hai", 1);
}

int SampleCPlusApps::Initialization()
{
const char* test;
    test = Connect1("197.1.1.1",1524); // my wrapper class is called here

}

so from my above code, i have doubt in SampleWrapper.cpp (C++/CLI wrapper).Here i have declared my c# dll(KinectV2Server::KinectV2 c1) inside the method.

But i need to declare the c# dll globally, so that it can be used in both functions namely connect1 and test.

Please assist me to fix the issue.

Thanks



kirubha

how to set propertygrid attributes and class functions in vc++

$
0
0
In property grid i got error in declarations and definitions.Here i refer many websites.here is my code

  private:bool _a;
private:String^ *_message;
[BrowsableAttribute(true)];
[DefaultValueAttribute(true)];
[CategoryAttribute("Appearance")];
[DescriptionAttribute("type1")];
[PropertyAttributes("property1")];
public:
  property bool a {
      double get() {
         return _a;
      }

      void set( bool newx ) {
         _a = newx;
      }

  property String^ *x {
      String^ get() {
         return _message;
      }

      void set( String^ newx ) {
         _message = newx;
      }

};

if i declare property means i have got error 1.IntelliSense: properties can only be members of managed classes

if i didnt put property means i have  got error1.expected a ';'.

Please  i need an example code for the class

C++ wofstream's bug in VS2013

$
0
0

When I typed following code in Visual Studio 2013,but the text file result is different,the function write_data_1() can't write chinese character to file "E:\test_1.txt",and when I use write_data_2() to write data,all of english and chinese character are right,Why? Is that a bug of wfstream in VC++ 2013?

#include <fstream>

using namespace std;

void write_data_1()
{
	wofstream wfs(LR"(E:\test_1.txt)");
	wfs << L"Line 01: Test chinese character 测试中文" << endl;
	wfs << L"line 02: Test english character " << endl;
	wfs.close();
}

void write_data_2()
{
	ofstream fs(R"(E:\test_2.txt)");
	fs << "Line 01: Test chinese character 测试中文" << endl;
	fs << "line 02: Test english character " << endl;
	fs.close();
}

int main()
{
	write_data_1(); // error
	write_data_2(); // right
}


code sample for _cgets_s

$
0
0

Can someone post a code sample that uses _cgets_s ?

I want to see how to declare the variables that will be used for the 1st and 3rd parameters.

errno_t _cgets_s(
   char *buffer,
   size_t numberOfElements,
   size_t *pSizeRead
);



Viewing all 15302 articles
Browse latest View live


Latest Images

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