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

MFC-MDI-Win7 Wild Flickering

$
0
0
My MFC MDI app with tabbed views works as expected when compiled with VS2008. But compiling the same code in VS 2013 (running on Win7) introduces a new feature: Instead of one button on the taskbar Win7 shows multiple buttons, one for each open document. Using these buttons I can select which of the tabbed views to display. 

BUT, when I do so the app flickers at a high rate for several seconds. The selected view is receiving numerous WM_PAINT messages for these several seconds. So it seems as if the VS2013 MFC has integrated somehow with a Win7 feature to show the multiple taskbar buttons, but then the implementation has something broken. I would be happy to just kill this "improvement" if someone knows what to override or change. 

calculating the probability of main characters in a string

$
0
0

i have a string from a user and i want to calculate the probability of each letter in this string 

i wrote this code in c++ but the probability comes to be zero i don't know why 

#include<iostream>
#include<fstream>
using namespace std;
#include<conio.h>
int main()
{ string x , y , unix , uniy ;
      int nx,ny,nux,nuy,countx,county ;
      cout<<"Enter the input message"<<endl;
      cin>>x;
cout<<"Enter the output message"<<endl;
cin>>y;
nx = x.length();
ny = y.length();
cout<<nx<<endl;
cout<<ny<<endl;
   unix =x;
   uniy=y;
sort(unix.begin(),unix.end());
unix.erase(unique(unix.begin(), unix.end()), unix.end());
cout<<unix<<endl;
nux= unix.length();
 
 int p[nux];


 for(int i=0;i<nux;i++)
  { 
      countx=0;
    for(int j=0;j<nx;j++)
     {if(unix[i]==x[j])
     countx ++;
        p[i]= countx;
      }
cout<<p[i]<<"\t";

}
sort(uniy.begin(),uniy.end());
uniy.erase(unique(uniy.begin(), uniy.end()), uniy.end());
cout<<uniy<<endl;
nuy= uniy.length();
int q[nuy];
for(int i=0;i<nuy;i++)
  { 
      county=0;
    for(int j=0;j<ny;j++)
     {if(uniy[i]==y[j])
     county ++;
        q[i]= county;
      }
cout<<q[i]<<"\t";

}
// probability p(X)
float probx[nux] , proby[nuy];
for(int i=0;i<nux;i++)
{
        probx[i]= p[i]/nx;
       
}
// probability p(y)
for(int i=0;i<nuy;i++)
{
        proby[i]=q[i]/ny;
        
}
for(int i=0;i<nux;i++)
{cout<<probx[i];}
getch();
return 0;
}

Graph Controls

$
0
0
Hello, I would just like to know how to create graph controls using C++ thru Windows API, just like in the Task Manager. Thanks.

How do you dynamically change the font size at runtime in a ATL dialog?

$
0
0

I need to change the font size in my ATL dialog templates at runtime (so that the entire dialog gets rescaled).  What is the best approach to do this?  The only solution I've found in the forums does this in a MFC project by modifying the dialog template.  I've looked at the MFC source but it does not seem to be an easy task to port it to ATL for my own use.  Here is the MFC code:

INT_PTR MyDlg::DoModal()
{
   CDialogTemplate dlt;
   int             nResult;
   if (!dlt.Load(MAKEINTRESOURCE(MyDlg::IDD)))
     return -1;
   dlt.SetFont("MS Sans Serif", 13);
   LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
   m_lpszTemplateName = NULL;
   InitModalIndirect(pdata);
   nResult = CDialog::DoModal();
   GlobalUnlock(dlt.m_hTemplate);
   return nResult;
}

Does anyone have an example of how to do this with ATL?


AliciaV

DockingPane with Splitter and RichEditctrl not returning GetSelText

$
0
0

I have a CDockingPane, with a SplitterWnd in it, and in both panes I have RichEditctrl in each.
When I ask it, if there is text in the window after I type text  with m_wndRightRichEditCtrl.GetTextLength()  it returns length and works fine...

IF I ask it, to tell me if the RichEditCtrl has Selected Text in it when I select text, it fails.. it keeps showing nothing??

If (m_wndRightRichEditCtrl.GetSelText().GetLength())TRACE("SELECTED***Text in SecoundPane \n");

CString strText=m_wndRightRichEditCtrl.GetSelText();

if( strText.GetLength() )
TRACE1("SELECTED***Text in SecoundPane is %s\n", strText);

Layout looks like this:

CToolbar
{
}

CSplitterWnd
{
}

CDockPane
{
   CSplitterWnd pWnd;
   CRichEditCtrl leftctrl,rightctrl;
   CToolbar toolbar;
}

Why is it failing to tell me the selected text when I ask the rightctrl directly?  When GetLength works fine? I tried splitter getpane, I tried EM_EXGETSEL, and EM_GETSELTEXT and all fail...?


Modal dialog become modalless

$
0
0

Hi,

I am working on a mixed mode application.

In my application(MFC), on click of a button, we will launch a modal dialog which is MFC. Within that dialog on click of another button I will launch another modal dialog which is a c# Winform. 

The problem is when I close the c# winform, the previous dialog becomes modeless. 

Even I had set the MFC dialog as parent to the C# Winform but still the problem exist.

Does anyone face such situation like that? Please help me on understanding this. I am using VS2008 IDE


-------------kings--------------

ATL COM Library Class Not Registered Error

$
0
0

I have an ATL COM project that creates a type library called Grouper. I have compiled this C++ ATL COM project and VS2013 automatically registers the library. Great. I then add a reference to this COM library in a C# WinForms application via 'Add Reference' > 'COM'. I can then use the library and with Native Code Debugging enable I can step into the source of the COM library.

Now, the problem. I need to provide this COM library to another developer with EXACTLY the same machine, OS and setup. I have provided both the solutions for the C++ ATL COM component and the C# WinForms application. I have ensured that VS2013 settings are identical. Now, on this second machine (Machine B) I compile the ATL COM library and I use OLE-COM Object Viewer and can see that the COM library has been registered and has the identical uuid to that on Machine A. I add a refernece to the COM library in the C# application on Machine B in exactly the same way as I did for Machine A. The types in reference COM library are resolved and the code compiles. However, now at run-time I am getting 

Retrieving the COM class factory for component with CLSID {A8E419AE-D60D-4FE5-95C0-A0B75DC1080B} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

I can see that this class is indeed registered using OLE-COM Object Viewer. So, why am I getting this error when the setups and environments are exactly the same? 

Thanks for your time.



"Everything should be made as simple as possible, but not simpler" - Einstein

How to sort datagridview in Visual Studio 2012 (VC++)

$
0
0

Hi,

I am using a dataGridView in my project and I am filling it by

dataGridView1->Rows->Add(id, time(NULL),x1 ,x2); // whatever

Now I am trying to sort it by the id, which contains just integer values.

I found many code examples for C# but I wasn't able to port it to VC++. :-(

I tried something like that:

SortOrder sortorder;
ListSortDirection direction;

dataGridView1->SortOrder = sortorder.Ascending;

// doesn't work

I hope you can help me.


ClistCtrl child window positioning problem.

$
0
0

hi all, 

i am trying to develop a clistctrl which having  process ring in all items.Here is a problem in positioning of process ring in vertical scrolling and horizontal scrolling .Pls help.

demo code is in

https://drive.google.com/file/d/0B5n6cYhn2ARTY2dRS3JIR0VOVEk/edit?usp=sharing


Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post

MFC SDI Maximize position error.

$
0
0

I have created a simple C++ sdi project to try this.

My desktop windows bar is on left, try to maximize this sdi application!

Note the position is 2x size of bar to the right.

Is it a bug? I'm using VS2012 - Up 4.


VC++ Programmer


how to play mp4 files in mfc

$
0
0

hi all, Please help to play mp4 files inside a MFC application.There are so many samples are for AVI file player.

thanks in advance, sarath s


Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post

how to Custom Draw button inside a Clistctrl with Icon view.

$
0
0

hi,

 how to Custom Draw button inside a Clistctrl with Icon view.Number of items in the clistctrl is more than 50 .Need to place or draw button above each item.

thanks, sarath s


Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post


error LNK2019

$
0
0

I Wrote a C++ program to  read data from IMU sensor. Besides, I got the following message

error LNK2019: unresolved external symbol __imp__LpmsSensorManagerFactory@0 referenced in function _main C:\Users\Selmy\Documents\Visual Studio 2013\Projects\Project1\Project1\main.obj Project1

Any help please?

Thanks in advance

I have a application developed in VC++ 6.0 in 2001. I am trying to migrate to Visual Studio 2010. But I get lots of compilation errors like below. Give me some hints on settings for Visual Studio 2010

$
0
0
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 25 1 ProjectName
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 26 1 ProjectName
Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 27 1 ProjectName
Error 14 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 28 1 ProjectName
Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 29 1 ProjectName
Error 20 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 30 1 ProjectName
Error 23 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 31 1 ProjectName
Error 25 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 32 1 ProjectName
Error 26 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 32 1 ProjectName
Error 28 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 33 1 ProjectName
Error 29 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 33 1 ProjectName
Error 36 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 52 1 ProjectName
Error 37 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 52 1 ProjectName
Error 44 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 89 1 ProjectName
Error 45 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 90 1 ProjectName
Error 48 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 91 1 ProjectName
Error 49 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 92 1 ProjectName
Error 52 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 95 1 ProjectName
Error 53 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 96 1 ProjectName
Error 59 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 112 1 ProjectName
Error 60 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 113 1 ProjectName
Error 63 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 114 1 ProjectName
Error 64 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 115 1 ProjectName
Error 67 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 120 1 ProjectName
Error 69 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 121 1 ProjectName
Error 72 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 124 1 ProjectName
Error 74 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 125 1 ProjectName
Error 77 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 128 1 ProjectName
Error 79 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 129 1 ProjectName
Error 83 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 130 1 ProjectName
Error 85 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 131 1 ProjectName
Error 89 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 132 1 ProjectName
Error 90 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 133 1 ProjectName
Error 93 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 134 1 ProjectName
Error 94 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 135 1 ProjectName
Error 97 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 136 1 ProjectName
Error 98 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 137 1 ProjectName
Error 101 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 138 1 ProjectName
Error 102 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 139 1 ProjectName
Error 110 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 150 1 ProjectName
Error 114 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 151 1 ProjectName
Error 120 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 200 1 ProjectName
Error 122 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 201 1 ProjectName
Error 125 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 205 1 ProjectName
Error 127 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 206 1 ProjectName
Error 132 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 231 1 ProjectName
Error 134 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 233 1 ProjectName
Error 138 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 242 1 ProjectName
Error 139 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 242 1 ProjectName
Error 140 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 242 1 ProjectName
Error 141 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 242 1 ProjectName
Error 183 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 25 1 ProjectName
Error 186 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 26 1 ProjectName
Error 189 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 27 1 ProjectName
Error 192 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 28 1 ProjectName
Error 195 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 29 1 ProjectName
Error 198 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 30 1 ProjectName
Error 201 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 31 1 ProjectName
Error 203 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 32 1 ProjectName
Error 204 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 32 1 ProjectName
Error 206 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 33 1 ProjectName
Error 207 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 33 1 ProjectName
Error 214 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 52 1 ProjectName
Error 215 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 52 1 ProjectName
Error 222 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 89 1 ProjectName
Error 223 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 90 1 ProjectName
Error 226 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int w:\build\release\include\FileName.h 91 1 ProjectName

VS 2010 fatal error C1083

$
0
0

Hi all, 

Hope someone can help me solve this issue.. I recently moved all my VS projects to a new computer I got and I'm trying to compile a project I have. The project is a VC++ one and it was developed using VS 2010 on a windows 7 computer. I have both VS 2010 and VS 2012 on my new computer (also windows 7); tried running my project on both of them but no success.. I'm getting the following error compiling it with VS 2010:

fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory

Any help?


Using Windows SDK 8.1 on a Windows 7 box

$
0
0

So I have a c++ application that builds on Windows 7 and Windows 8 using Visual Studio 2013. The app uses DirectX via the Windows 8.1 SDK so all box, including the Windows 7 ones, have that installed.

So recently someone added some code related to time of day that boils down to

   #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
      GetSystemTimePreciseAsFileTime(&fileTime);
   #else
      GetSystemTimeAsFileTime(&fileTime);
   #endif

Note the app already has a Windows 7 and a Windows 8 specific build so at first glance I thought the above would be OK. However it compiles but fails at run time. Eventually I discovered this is because the Windows 8.1 SDK defines _WIN32_WINNT to be _WIN32_WINNT_WINBLUE ( 8.1 ) even when building on a Window 7 box. This means there is a declaration for GetSystemTimePreciseAsFileTime and the above code compiles. However GetSystemTimePreciseAsFileTime lives in Kernel32.dll which is not part of the Window 8.1 SDK and so the code fails at run time with an undefined symbol.

So my question is, why would the Windows 8.1 SDK behave this way. It seems to me that adding declarations for things that are not actually available on the platform on which you are compiling or targeting is a bit odd.

As usual I assume I am misunderstanding something here, so is there for instance a better way to find out the OS version on which you are actually building ( or at least targeting )? ideally I would like to use GetSystemTimePreciseAsFileTime if it is available on the platform I am running on and GetSystemTimeAsFileTime if not and do away with the #ifdef but I'm not sure of a good way of doing that.

Any feedback gratefully received.

How can i oad varbinary from database?

$
0
0

have a good time

i puted a file int the database with varbinary(max) type.

now i want to load the file from the database in the my app. i work with visual C++ 2013.

i know that how open and connect to database with VC just i don't know can i extract the data from that.

i heard that i should work with CBinaryArray or CBinaryLong. Is it correct?

please help me

i am not able to build the USBDLL in 64 bit machine but same USBDLL is working in 32 machine

$
0
0

Hi,

i am not able to build the USBDLL in 64 bit machine but same USBdll is working in 32 machine.

could you please help me how to resolve these 2 errors. please see the below errors in bold letters

error LNK2001: unresolved external symbol "extern "C" void __cdecl HidD_GetHidGuid(struct _GUID *)" 

error LNK2001: unresolved external symbol "extern "C" unsigned char __cdecl HidD_GetAttributes(void *,struct _HIDD_ATTRIBUTES *)




Visual Studio 2013 custom build tool is executed only for one file

$
0
0

After migrating C++ projects from Visual Studio 2008 to 2013 custom build step stopped working properly. It is now executing custom build step only for some files. In one project of the same solution custom step is executed only for one file and in another project for two files. Visual Studio shows no warnings and all files with custom build steps can be "compiled" manually.

Project compiled fine in VS 2008 and now it is refusing to build all custom steps in VS 2013.

Any ideas what could be wrong with this? It looks like VS2013 bug to me but maybe I am missing something obvious.

Is there a working C++ refactoring tool ?

$
0
0

Does anybody know a fully featured refactoring tool for C++ that works reliably with large code bases (some 100.000 lines)? with around 2000 variables (global and local) ?

I know this question has been asked repeatedly but i have found most them were asked quite long ago, so if anyone has any update/suggestions/recommendations ?

Viewing all 15302 articles
Browse latest View live


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