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

Why is the Default Beep Triggered by CreateWindowEx?

$
0
0

Hi,

When creating a rich edit control via "Create" on Windows 7 64-bit, the default beep is triggered.  This happens in the "CreateEx" method in wincore.cpp, specifically after the call to "CreateWindowEx". A proper handle is returned and there is no error, just a beep.  The window is properly created as far as we can tell.

Our application is a native c++, mfc, unicode.  Here is the code for creating the edit control:

HINSTANCE hRichEditLib = LoadLibrary(_T("Riched20.dll"));

CRect rectDummy(0, 0, lpCreateStruct->cx, lpCreateStruct->cy);

const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_AUTOSCROLL | ES_AUTOVSCROLL | ES_MULTILINE;

if (!myCtrl.Create(dwStyle, rectDummy, this, 2))  //this line triggers the beep

{

  return -1;

}

else

{

  myCtrl.Initalize();

}

Any ideas as to why the beep is triggered would be greatly appreciated! Thanks.


VS2012: c:\program files\microsoft sdks\windows\v7.1\include\sal_supp.h(57): warning C4005: '__useHeader' : macro redefinition

$
0
0

Just making my first steps with VS2012. But it fails by default. I get following errors when compiling a *newly* created MFC project:


1>------ Build started: Project: Test2012, Configuration: Debug Win32 ------
1> stdafx.cpp1>c:\program files\microsoft sdks\windows\v7.1\include\sal_supp.h(57): warning C4005: '__useHeader' : macro redefinition
1> m:\program files (x86)\microsoft visual studio 11.0\vc\include\sal.h(2872) : see previous definition of '__useHeader'
1>c:\program files\microsoft sdks\windows\v7.1\include\specstrings_supp.h(77): warning C4005: '__on_failure' : macro redefinition
1> m:\program files (x86)\microsoft visual studio 11.0\vc\include\sal.h(2882) : see previous definition of '__on_failure'
1>m:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlcore.h(638): error C2039: 'SetDefaultDllDirectories' : is not a member of '`global namespace''
1>m:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlcore.h(638): error C2065: 'SetDefaultDllDirectories' : undeclared identifier
1>m:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\atlcore.h(640): error C2065: 'LOAD_LIBRARY_SEARCH_SYSTEM32' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I've seen a similar thread:
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/a7fd6119-825a-4d9a-9570-7b9cf6ed1bc6
But it doesn't work for me...

Adjusting the project's include paths seems to get ignored. I changed it from:
$(VCInstallDir)PlatformSDK\include;C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;$(IncludePath)

to:
$(VCInstallDir)PlatformSDK\include;C:\Program Files (x86)\Windows Kits\8.0;$(IncludePath)

at:
project properties > configuration properties > VC++ Directories

But nothing changed. Even though I removed the "7.1" for the directories, it is STILL listed in errors as shown above.

So weird.

How do include directories work with VS2012?
Why does it fail by default on my PC?

Thanks!

For MFC ON_EVENT function,how to realize it from the windows api level

$
0
0

In MFC,create ActiveX event handler such as below:

BEGIN_EVENTSINK_MAP(CTestExecDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CTestExecDlg)
ON_EVENT(CTestExecDlg, IDC_APPLICATIONMGR, 1 /* ExitApplication */, OnExitApplication_ApplicationMgr, VTS_NONE)

//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

How could I realize it from the windows api level?

Thanks


C++ equivalent of Event in C#/VB.NET

$
0
0
In case of C#, VB.NET or VB6, the Event exists in those programming language but I can't find it in C++.
What is the C++ equivalent of Event?
If there's no equivalent, how could I made code for functionality of event?

Captureing diffrent images from a 3D image

$
0
0

Hello!

I am building an app that captures different screenshot from a 3D image file such as .3ds and .stl files. It captures a screenshot from the object, rotate it by 90 degrees for example, capture a new shot and so on, then exporting them as images with transparent background is preferred (4 PNG files in this case) or with black background for example?

Later, I'll use the images to create single black grounded image containing the 4 captures sorted radially around a center.

I think I can do the other part but I have no idea where to start for the first part. It would be great if I made the final image in one step instead of exporting images then remove the black background (if it exists), then doing processes on the exported images to create the single final image (as mentioned before).

Any suggestions how to achieve this?
Thanks in advance,

Samuel Farid

Unable to save WMF image file.

$
0
0

Hi,

i am new to this topic. Please help me how to save a wmf file.

I am successfully loading the WMF file using  CMyImage class.

But when i saving after riotating the picture, it is not saving.

image.save function supports all other formats like .bmp,.jpeg,.gif,.png but coming to .wmf it shows the error like 

 

" Save failed : 80004005 - Unspecified error ".

please help me regarding this.

Thanks inAdvance.



sree2sri

How to convert CBitmap to WMF file using C++?

$
0
0

Hi,

How to convert CBitmap to WMF file using C++?

Thanks in advance.

CFileDialog cannot resize on winows 10

$
0
0

Hi everyone,

I have a custom file dialog using  custom template derived from CFileDialog, as follow

// In constructor

m_ofn.Flags |= OFN_ENABLESIZING | OFN_ENABLETEMPLATE; m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FILEDIALOG);

The file dialog box can resize on WinXp and Win7, But not on Win10( can be zooming in, cannot be zooming out)

I found that OnSize() function in my code is not responding when zoom out the dialog on win10.

Who can tell me why and help me. Thanks




Issue with mfc110ud.dll

$
0
0

We are getting the following error message in our application:

"information not available, no symbols loaded for mfc110ud.dll"

It seems that the issue arise due to the fact that the dll is not loaded correctly.    
Kindly note that the same issue is not observed in the Win 2008R2 boxes. Also, there have been no code changes from our end as well. This issue seems to be present in all later versions of Windows OS like Win8, Win7 etc

Any method that is called in this dll is being returned as NULL - such as GetDlgItem. 

What has changed? Please let us know.

Thanks,

Vishal

Problem with output file

$
0
0

Hi,
how to resolve these

Error 2 error C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\dp11\dbserver 150927\dbserver\bayertree.h 264 1 DBServer
Error 3 error C3861: 'time': identifier not found c:\app2\t1.h 263 1 DBServer
Error 4 error C3861: 'localtime': identifier not found c:\app2\t1.h 264 1 DBServer
Error 5 error C3861: 'strftime': identifier not found c:\app2\t1.h 266 1 DBServer

due to these
258  t00.open("c:\\00.txt");
259  time_t rawtime;
260  struct tm * timeinfo;
261  char buffer[80];
262
  time(&rawtime);
  timeinfo = localtime(&rawtime);


  strftime(buffer, 80, "%d-%m-%Y %I:%M:%S", timeinfo);
  std::string str(buffer);


  //
  t00 << str;


  t00.close();


Many Thanks & Best Regards, Hua Min

Unable to save WMF image file.

$
0
0


Hi,

i am new to this topic. Please help me how to save a wmf file.

I am successfully loading the WMF file using  CMyImage class.

But when i saving after riotating the picture, it is not saving.

image.save function supports all other formats like .bmp,.jpeg,.gif,.png but coming to .wmf it shows the error like 

 

" Save failed : 80004005 - Unspecified error ".

please help me regarding this.

Thanks inAdvance.


sree2sri

C++/CLI open file

$
0
0

Hi, I'm having real problem with opening file in textBox:

OpenFileDialog ^ofd = gcnew OpenFileDialog();
if (ofd->ShowDialog() == System::Windows::Forms::DialogResult::OK) {
StreamReader ^read = gcnew StreamReader(File->OpenRead(OpenFile->FileName));
	textBox1->Text = read->ReadToEnd();
}

C++/CLI how to make text split of the first line

$
0
0
I have a text in which the first line is author's name, second is blank and from the third normal text starts. I want to (separate/split) the first line whit author's name from the remaining text.

std::vector, std::find and std::weak_ptr

$
0
0

Hello All,

I am trying to use vectors of weak_ptrs and at times I need to know if the vector contains a "pointer" that "point" to the same item. Below is a simplified example of what I am trying to do...

#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>



using namespace std ;



// Return true if either they have both expired or they both "point" to the
// same object.
bool operator== (const weak_ptr<int>& lhs, const weak_ptr<int>& rhs )
{
	cout << "In specialised ==" << endl;
	return ( lhs.lock() == rhs.lock() ) ;
}



int main()
{

	// Create some shared_ptrs from which we will create the weak_ptrs
	shared_ptr<int> Sp1 {new int } ;
	shared_ptr<int> Sp2 {new int } ;
	shared_ptr<int> Sp3 {new int } ;
	shared_ptr<int> Sp4 {new int } ;



	// Create the weak_ptrs
	weak_ptr<int> Wp1 {Sp1} ;
	weak_ptr<int> Wp2 {Sp2} ;
	weak_ptr<int> Wp3 {Sp3} ;
	weak_ptr<int> Wp4 {Sp4} ;



	// Put weak_ptrs into the vector
	vector<weak_ptr<int>> Vwp {Wp1, Wp2, Wp3, Wp4} ;

	// Verify that my operator == method is working as I expect.
	if (Wp1 == Wp2) cout << "That's odd!" << endl;
	else cout << "That was expected" << endl;
	weak_ptr<int> Wp5{ Wp1 };
	if (Wp1 == Wp5) cout << "Wp1 equals Wp5 -- good" << endl;
	else cout << "Wp1 not equals Wp5 -- bad" << endl;



	// The block of code that fails...
	if ( find ( Vwp.begin(), Vwp.end(), Wp2 ) == Vwp.end() ) cout << "Not in list" << endl ;
	else cout << "In list" << endl ;


}


Because weak_ptr does not provide an operator== method, I have provided my own. I have added code that checks that the operator== is doing what I want it to do (and certainly at a simplistic level it does). My problem is that I cannot use std::find with the vector of weak_ptrs. I get the following compiler error:

Error    C2678    binary '==': no operator found which takes a left-hand operand of type 'std::weak_ptr<int>' (or there is no acceptable conversion)    Project1    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xutility    3134

I do not understand this, since I have provided and operator== (and I know it "works" because if I comment out the "find" code the program behaves as I expect).

I can work around this by using "find_if" and a lambda -- but so far I have not been able to get any elegant code that is anywhere near as obvious as to what I am trying to do.

Can anyone tell me why my example does not work (especially as as I have provided an operator==)? If find / vector / and weak_ptr cannot be made to work together, can anyone suggest code to replace the find that does not obfuscate the intention.

Thanks in advance.

Andrew Ch

sin function returns different results from VS2015 and VS2010

$
0
0
Hello,

I got some differences between sin function compiled with VS2015 and VS2010.

double t=4.1887902047863905;
double dRes = sin(t);

Result in VS2015 64 bits is: 
   -0.86602540378443849  (hexa:-0x1.bb67ae8584ca9p-1)

Result in VS2015 32 bits, VS2010 32 and 64 bits is:

   -0.86602540378443837  (hexa:-0x1.bb67ae8584ca8p-1)

Difference is small, but I would like to compile project with VS2015 64 bits and obtain the same result, or at least to understand where the difference come from.



File can be downloaded at 

h**ps://onedrive.live.com/redir?resid=FB5FF8CA6A484116!145&authkey=!AJH9CzM9FTdBZ50&ithint=file%2crar

Thanks,

Best regards,

Marc S.


How to pass a unicode string to the FDF Toolkit (adobe)?

$
0
0

Hi

I am very confused here. According to the FDF Toolkit it states:

	/* IMPORTANT NOTE about all strings in this API: All strings must be null-terminated.
	Every call specifies which encodings are acceptable for every string. Strings that are in Host-
	or PDFDocEncoding end with a single null byte. Strings in Unicode have '\xfe' as byte 0
	and '\xff' as byte 1. Additionally, they must be terminated with 2 null bytes.
	Field names are always in PDFDoc encoding, and they always represent the fully qualified
	name of the field (e.g. "employee.name.last").
	The PDFDocEncoding is described in Appendix D of the PDF Reference, Second Edition.
	*/

So, I have a CString which has a bit of Arabic text. I am trying to convert it into a suitable buffer (char *) so I can use the FDFSetValue call.

I tried:

CString strArabic = _T("كانون الاول");

strArabic.Insert(0, '\xfe');
strArabic.Insert(1, '\xff');
strArabic += '\0';

LPCSTR zBuffer = (LPCSTR)strArabic.GetBuffer();

Doesn't work. The resulting FDF document is not right.

I have heard about the PDFEncoding and think it might be supposed to be like that since the original FDF file is in ANSI format.

I am very confused and appreciate any pointers.

Andrew

how could/should you write an native application without using windows.h

$
0
0
wondering how you could/should you write an application without using windows.h. Write your own API and everything from the ground up.

Unit Testing

$
0
0
What is the difference between Unit Test APP(Universal Windows) and Native Unit Test Project and when should i use each of them?

Direct3D D3DCompileFromFile not recognized

$
0
0

I'm trying to work with Direct3D. Unfortunately, there is a function called "D3DCompileFromFile" that my Environment does not recognize despite it being documented in the MSDN website here:

https://msdn.microsoft.com/en-us/library/windows/desktop/hh446872%28v=vs.85%29.aspx

I'm even using the line

#include <D3Dcompiler.h>

and have a library listed as shown in the snip below, using the library "D3DCompiler.lib" listed in the online documentation.

I have the June 2010 kit installed and I'm sure the properties are pointed in the right direction, given an earlier build compiled despite my code already using devices, swapChains, contexts, and render targets.

Also, I tried using a work around with "D3DX11CompileFromFile" but while Intellisense recognizes it, the compiler flags it, either by failing to link it or failing to open the "d3dx11.lib" file, which is present (and listed after the snip was made)

OS: Windows 8.1 Pro

VS: 2013 Professional

Mixing the flags of RedrawWindow()

$
0
0

The RedrawWindow() documentation separates most of the flags into two groups:

  • The following flags are used to invalidate the window: RDW_ERASE, RDW_FRAME, RDW_INTERNALPAINT, RDW_INVALIDATE.
  • The following flags are used to validate the window: RDW_NOERASE, RDW_NOFRAME, RDW_NOINTERNALPAINT, RDW_VALIDATE.

Can I mix these flags together, for example is this a correct call:

RedrawWindow(hWnd, &rc, NULL, RDW_NOERASE | RDW_INVALIDATE | RDW_UPDATENOW);

Viewing all 15302 articles
Browse latest View live


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