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

Two non modal dialogs

$
0
0

I have an non modal dialog, and I launch it twice, but first one I want to be top most, but only for the current application ... is it posible to do such thing ? Can you give me a way to go in order to complete that ? Thank you.


Where's to start C++ Console/Gui programming perfectly ?

$
0
0

Hello community, I'm an old Pascal/Delphi developer ... i have to move to programming everythings in C++ both console/gui ... my big problem is i don't have any knowledge, would be very usefull for me if someone can provide me a really helpful link or page to a great tutorial ... thank you very much !

masm 16-bit

$
0
0

how to assemble,link and debug assembly language programs that addresses 16 bit registers or 8 bit registers using masm in 64 bit windows 8?

Alignment of ReBar Contents

$
0
0
Hi, am developing a MFC application, In my application i have 9 toolbars, and i arranged them in two rows by using CMFCReBar, the problem is that the alignment of toolbar in each ReBar row is not aligned well the code block and resulted output image is attaching, i would like to know how to allign them well or how to set the width of toolbar in a rebar, actually my requirement is multiple row of my toolbars,  thanks in advance
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{

	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	
	// Like above i have created toolbars tb1,tb2,tb3,tb4,tb5,tb6,tb8


	if (!rebar1.Create(this) ||
		!rebar1.AddBar (&m_wndToolBar, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) ||
		!rebar1.AddBar (&tb4, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) ||
		!rebar1.AddBar (&tb7, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) ||
		!rebar1.AddBar (&tb8, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) 
		)
	{
		TRACE0("Failed to create rebar\n");
		return -1;      // fail to create
	}

	rebar1.AdjustLayout();
	tb1.AdjustSize ();
	m_wndToolBar.AdjustSize ();
	tb4.AdjustSize();
	tb8.AdjustSize ();
	tb9.AdjustSize();

	if (!rebar2.Create(this) ||
		!rebar2.AddBar (&tb1, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) ||
		!rebar2.AddBar (&tb2, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) ||
		!rebar2.AddBar (&tb3, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) ||
		!rebar2.AddBar (&tb6, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) ||
		!rebar2.AddBar (&tb7, NULL, NULL, RBBS_GRIPPERALWAYS | RBS_AUTOSIZE ) 
		)
	{
		TRACE0("Failed to create rebar\n");
		return -1;      // fail to create
	}

	rebar2.AdjustLayout();	
	tb1.AdjustLayout();
	tb2.AdjustLayout ();
	tb3.AdjustLayout();
	tb6.AdjustLayout();
	tb7.AdjustLayout();
	

	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
	
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	
	rebar1.EnableDocking(CBRS_ALIGN_ANY);
	rebar2.EnableDocking(CBRS_ALIGN_ANY);

	EnableDocking(CBRS_ALIGN_ANY);
	
	DockPane(&m_wndMenuBar);
	DockPane(&rebar1);
	DockPane(&rebar2);

	return 0;
}








A learner


ActiveX bitmap push button built in VS 2013

$
0
0
I migrated an ActiveX project from VS 2008 to VS 2013 that has various controls including bitmap push button. When I build under C++ VS 2013, the control works in dialogs but is disabled in CDialogBar derived classes. I am not sure why VS 2013 build works incorrectly?

batchapi.dll is missing from the computer

$
0
0

Hi

I am migrating my application from vc++6.0 to vc++2008

I have migrated it successfully and removed all the errors, after that i was trying to create the package manually.

i ran one of the exe and got an error message " the program can't start because batchapi.dll is missing from your computer.Try

reinstalling the program to fix this problem "

I need that exe to run for testing purpose.

When i searched for batchapi.dll it was not found any were but batchapi.lib and batchapi.h was there in one of my vc++ component.

Should i create batchapi.dll from those component or i need to download it from net.

Can any one suggest me ASAP

Thanks Ankush

COleDateTime initialize

$
0
0
I'm developing a DLL function which initializes a C++ COleDateTime object based on the function parameters.
 
Given that the DLL host that calls the function only has year, month, day, hour, minute & second data available is there an efficient way to pass this data to the function so the COleDateTime can be initialized?

MFC - Bug in CMFCPopupMenuBar::ImportFromMenu with Non-Permitted Commands and Separators

$
0
0

Sorry for the long title but it summarises very well the bug I just discovered in MFC after a long debugging session...

The issue is as follows and is easily reproducible:

1/ Create a default MFC application (SDI or MDI, doesn't matter).

2/ Edit its default Menu resource and add the following 5 entries in one of the menus:

  • Command1
  • - Separator -
  • Command2
  • Command3
  • - Separator -
  • Command4

3/ Upon initializing the CFrameWnd-derived main window, set the IDs of Command2 and Command3 as non-permitted. This is done through CMFCToolbar::SetNonPermittedCommands.

4/ Now compile and launch, then click on the menu entry you've modified in the menu bar. You'll get the following results:

  • Command1
  • - Separator -
  • - Separator -
  • Command4

I was expecting to see only one Separator, which clearly indicates a bug.

Now, I've found where the problem lies. If you go to the MFC source files, in "afxpopupmenubar.cpp", you'll see the member function called "CMFCPopupMenuBar::ImportFromMenu". At first sight, it looks like the developers took care of successive separators with the use of BOOL bPrevWasSeparator. The problem is that it's reset to FALSE whenever a non-separator menu item is added even if it's been rejected because it's part of the non-permitted commands!

The culprit part lies after the "if (m_bTrackMode || bShowAllCommands || CMFCMenuBar::IsShowAllCommands() || !CMFCToolBar::IsCommandRarelyUsed(uiCmd) || m_bPaletteMode)" statement. In there, we've found a command ID that is not a separator. A few lines down, we add a button for this command to the popup menu bar through "iIndex = InsertButton(item);". This is where the magic of SetNonPermittedCommands comes into play: within this "InsertButton" function, we test if the command is permitted or not. If it is, the button is added and the index returned. If it isn't we return -1 as the index.

A few lines down again, we see that there's a check on iIndex to make sure the button has been added ("if (iIndex >= 0)"). Trouble is, the reset of BOOLs "bPrevWasSeparator" and "bFirstItem" is down outside of this "if" statement, which means that even if the button has not been added, we're considering that the previous item was not a separator!

The fix is easy, simply put the two BOOLs reset within the "if" statement, and the bug will be gone. Now, I realise we won't get a fix for this tomorrow so I'll have to find a way to recompile a custom version of MFC that fixes the issue...

Best regards,

Eric


Speak SAPI error 8004503a when using SDK 11 in Win32 Project on Windows 7 64 bit

$
0
0

I am running Windows 7 64 bit Enterprise SP 1 and Visual Studio 2013 Express.  I have the Windows SDK, Kinect 1.8 SDK and the Microsoft Speech SDK installed.

I only have a problem with Speak when trying to use it in a Win32 Project that has the include and lib directories specified for C:\Program Files x86\Microsoft SDKs\Speech\v11.0\.  I noticed the problem when trying to modify the SpeechBasics-D2D Kinect sample to include speech.  That sample requires C:\Program Files x86\Microsoft SDKs\Speech\v11.0\ include and lib directories to be specified.  I have created a C# x86 WPF application that uses speech successfully and if I create a new Win32 Project and don't specify C:\Program Files x86\Microsoft SDKs\Speech\v11.0\ then Speak works (although the voice sounds more tinny then C# app.  I am at a loss for what to check.  I read an article about someone having problems with WOW64 redirection here that sounded similar to my problem but am not sure what to check:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/b56c8dab-8f4d-4f84-bc6f-2b9ab4e9f914/sapi-loaddictation

I can provided more config information or sample code if needed.  Any help appreciated.

Create Scrollbar in SDI

$
0
0
I have an MFC SDI application, and I set aside the rectangle bounded by the left 200 pixels of the window for a listing of files. I am now finding out I didn't plan all that well, and that the listing is too long to go in the rectangle I have set aside, so I want to add a vertical scrollbar in the window on the right side of the 200 pixel boundary (not on the right side of he SDI window), that scrolls the listing in the rectangle. I would like to use CScrollbar, and I have found all the  public methods (Create, EnableScrollBar, etc.). However, I really need an example that shows how to set all this up. Google hasn't been help with this. Thanks.

[VS2013, C++] Initializer list in Ctor

$
0
0

Consider the following code:

#include <iostream>
#include <string>

using namespace std;

int main()
{
    set<string> ssA{ { "a", "b" } };
    set<string> ssB( { "a", "b" } );

    for (auto s : ssA)
    {
        cout << s << endl;
    }

    for (auto s : ssB)
    {
        cout << s << endl;
    }    

    return 0;
}
Isn't ssA expected the same as ssB ? While, it throws a run-time error, 'cos the Ctor of ssA is taken as "set<string>(_Iter _First, _Iter _Last)", which will obviously try to cast stirng to _Iter .

Is it a feature or a bug or something else?

Tooltips stopped working after migrating from VS 2005 to VS 2010

$
0
0

Hi,

My code in a C/C++ app to create and update tooltips stopped working between VS 2005 and VS 2010. The tooltip was created using:

hwndTT = CreateWindow(TOOLTIPS_CLASS, TEXT(""), WS_POPUP,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, W_USEDEFAULT, NULL, (HMENU)NULL, hinstDrawbase, NULL);

This succeeds in VS 2005 and in VS 2010. If I then setup the tooltip structure and add the tooltip using:

SendMessage(hwndTT,TTM_ADDTOOL,0,(LPARAM)&ti);

This succeeds in VS 2005 and in VS 2010. If I then setup the tooltip structure to get the tooltip info using:

SendMessage( hwndTT, TTM_GETTOOLINFO, (WPARAM)0, (LPARAM)&ti );

This succeeds in VS 2005 but fails in VS 2010. The failure in VS 2010 gives last error as 0 (indicating S_OK) when using

dwError = GetLastError();

I have been using one tooltip window whose owner is a frame window whose child is an MDI window. This MDI window becomes the parent of multiple static text and edit control child windows. I was updating and activating/deactivating the tooltip window as the mouse moved over the static text and edit control child windows. I tried ignoring the error from the SendMessage to get tool info since last error says S_OK and tried sending messages to update the tool info and activate the tooltip anyway, but to no effect. So the "key" falure seems to be related to the TTM_GETTOOLINFO failure.

Can anyone help?

Thanks, Chris

How to download offline installer forCryptographic Provider Development Kit offline without administrator rights or .net framework 4.0?

$
0
0
I downloaded the cryptographic provider development kit, which gave me a file called cpdksetup.exe. When I took this to the system where I need to use it (where I have .Net framework, visual studio express etc. installed but which is not allowed to connect to the internet), it gives me a choice of either installing to that computer or downloading for installation to a separate computer, but both require internet access to get "Cryptographic Provider Development Kit-x86_en-us.msi". So I need to get hold of that. So I went back to the system that's connected to the internet and tried running cpdksetup.exe there, but User Account Contro then wanted an administrator password, before getting to the choice between installation or download. This doesn't make sense, I shouldn't need administrator rights to download something to install elsewhere. I have the impression that it may be trying to install .Net Framework first (as that seems to be a prerequisite), but I'm not certain of that. Anyway, the basic question is, how can I download "Cryptographic Provider Development Kit-x86_en-us.msi" for use on another system, when the only systems I'm allowed to connect to the internet have neither .NET Framework 4.0 nor administrator rights?

windows socket gets quite slow after sending some MB of data

$
0
0

I have programmed a server in Linux that sends the file you ask for. If I use the client programmed also in Linux the transmission works perfect, but when I use a client programmed in visual C++ it start working fine but after transmitting several MB (sometimes 60.. sometimes 70..) the socket becomes very slow. Is there any issue with windows sockets about this? 
I include the code of the main sending loop. The socket is blocking (I added the select call in the last test, just in case.. but it didn't fix the problem)

while(1){
   FD_ZERO(&rfds);
   FD_SET(sockfd,&rfds);

   if((n = select(0, &rfds, NULL, NULL, NULL)) < 0){
	printf("select failed");
	    goto error;
	}

	n = recv(sockfd, buffer, sizeof(buffer), 0);

	if(n < 0){
		printf("Error receiving: %d\n", n);
		goto error;
	}else if(n == 0){
		printf("Connection lost\n");
		break;
	}
	count += n;
	printf("bytes received: %ld\r", count);

	try{
	   if((n = _write(fd_out, buffer, n)) != n){
		printf("write file failed\n");
		goto error;
	   }
	}catch(...){
	   printf("Error writting file\n");
	   goto error;
	}



I am really stuck. Any help or clue will be very appreciated!

Windows 8 Csrss.exe Dll Inject - RtlCreateUserThread working with API DLL but my dll is not

$
0
0

Hi,i try to inject my dll to window 8 64bit Csrss.exe with RtlCreateUserThread function,RtlCreateUserThread working good but my dll cannot load while i tried with window api dll and it's working good,anyone can help me solve it?

thank you very much :D,sorry my bad english ^^.


fseek() not returning an error (but it should)

$
0
0

Hi,

See the simple program below.  It reads a binary file (written by another, almost identical program) in a 88-byte structure.  In my tests, there are exactly 3 records on disk so the file has (3*88) bytes or 264.  The program asks which book you want to read from the file (1=first, 2=second, 3=third).  And it works.  However, if I type in 4, 5, 10, or 10000, fseek() does not return an error.

Any idea why?  Thank you.

* readbook.c -- reads a book structure from the disk */ #include <stdio.h> #include <stdlib.h> #include <string.h> typedef enum { FALSE, TRUE } boolean; struct book { char title[ 40 ]; char author[ 40 ]; float value; boolean isDeleted; }; int main( void ) { struct book oneBook; int count = 0; int index = 0; int filecount; int nBook = 0; FILE *pbooks; long size = sizeof( struct book ); /* Try to open the file in read mode. */ if( ( pbooks = fopen( "book.dat", "r") ) == NULL ) { fputs( "Can't open book.dat file.\n", stderr ); exit( 1 ); } puts( "Indicate which book you want to read: "); scanf( "%d%", &nBook );

rewind( pbooks ); index = fseek( pbooks, nBook*size, SEEK_SET); if( nIndex == 0 ){ printf("\nError **Out of bounds**\n"); exit(1); } printf ("\nResult of index: %d", index ); /* Alyways Zero ?! */ fread( &oneBook, size ,1,pbooks ); printf("\nAuthor: %s\n", oneBook.title ); printf("IsDeleted: %d\n", oneBook.isDeleted ); }



Stephane


VS 2013 error LNK1104: cannot open file atlsd.lib

$
0
0

I'm trying
to get a VS 2010 C++ ATL based dll to compile in VS 2013.  I'm getting the
following link error: <o:p></o:p>

error LNK1104: cannot open file atlsd.lib   

I've not
been able to find any references to this library in the project
properties.  How do I fix this

I'm aware that the atl libraries have changed in VS 2013 but have not been able to figure out how to correct the link problem.


AliciaV

BSCMAKE: error BK1506 : cannot open file '.\ReleaseMinSize\ArmesDataManager.sbr': No such file or directory

$
0
0
I have converted one of my VS2006 projects into VS2008 and when trying to build the project in VS2008 I get the above error. What is .sbr file ? and how can I fix the compile error? Any help is hugely appreciated.

I am facing one error, i.e. error C4772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder

$
0
0
I have a C++ project that contains a importTDApplication.h file which tries to import a TLB (we'll call it td_appl.tlb). When I go to compile the project I get an error on the line

Toolbar alignment in MFC

$
0
0
Hi, am new to MFC development, Learning the basics, i just create a sample mfc application containing 8 toolbars, i want to appear them as follows

T1-T2-T3-T4
T5-T6-T7-T8

but they always appear as follows

T1-T2-T3-T4-T5-T6-T7-T8


How to bring the toolbars in to multiple rows? i have no idea to achieve this, help should be appreciated thanks in advance :) 
Viewing all 15302 articles
Browse latest View live


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