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

MFC CBrush Hatch Failed On PDF Output

$
0
0

Hi, I am working on a project with output to PDF or printer, etc.

My development environment is Windows XP Professional Version 2002 Service Pack 3

and the development tool is MFC on Microsoft Developer Studio Visual C++ 4.2.

I'm facing a problem when the output is PDF. Right now, I use Acrobat PDFWriter to

output the PDF file.

The problem is, I want to display a rectangle with gray hatch brush but it fails to output the

hatch brush, it only print the standard gray brush.

For that purpose, I use this code  in my print function.

//================Code_Snippet_1=========================

CBrush cBrush( HS_FDIAGONAL, RGB(80, 80, 80) );

pDC->SelectObject( &cBrush );

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

I have also tried another way of creating the hatch styled brush by using these codes:

//================Code_Snippet_2=========================

WORD HatchBits[8] = { 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe };

CBitmap bm;
bm.CreateBitmap( 8, 8, 1, 1, HatchBits );

cBrush.CreatePatternBrush( &bm );

pDC->SelectObject( &cBrush );

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

 

The result is both of above codes are failed to output the hatch brush on PDF.

What is wrong or what do I need to add to my code to successfully output the hatch brush on PDF?

 

Thank you very much.


Getting error -- "Unable to start program 'C:\.......\debug\sample.exe'. The system cannot find the file specified"

$
0
0

I have re-installed it and YES I have tried to check the path to see if the file is there (the .exe file is there). 

I cannot, for the life of me, seem to get this thing to work. 

I tried everything of the following:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/e60f9f37-69ad-47f3-b1d3-132aabe68f86/unable-to-start-program-the-system-cannot-find-the-file-specified?forum=vsdebug

http://social.msdn.microsoft.com/Forums/vstudio/en-US/4253e88a-7a32-48fd-b2fa-093bf41fcb38/unable-to-start-program-cexe-the-system-cannot-find-the-file-specified?forum=visualstudiogeneral

http://social.msdn.microsoft.com/Forums/vstudio/en-US/9816c136-e07b-4540-b63b-a3ed36e24ed8/unable-to-start-program-the-system-cannot-find-specified-path?forum=vsdebug

http://social.msdn.microsoft.com/Forums/vstudio/en-US/3b8ffe5b-7b71-4218-a8fd-b8e8cb5e6168/unable-to-start-debugging-unable-to-start-programthe-system-cannot-find-the-file-specified?forum=vsdebug

VS C++ 2010 seems to have an issue with me ! Please tell me how to fix! I tried doing this on TWO different computers and TWO diffeent versions of the VS (2005 and 2010) and they both showed me same issues. I reinstalled it and installed in (newly) to my other desktop but they are both giving me the same message. I checked if my code was wrong but honestly it was THIS:

#include <stdio.h>

int main(void){

printf("Hello\n");

return 0;

}

 

IT WAS NOTHING AND IT SHOULDN'T HAVE GIVEN ME TROUBLE. I'm actually pretty sure something is conspiring against me, but in the meanwhile, please help me! I'm desperate...

Thanks in advance,

Lil

THIS is the picture btw: 

http://imgur.com/X5TvFZw

http://imgur.com/GQcyiHX

How to add a Rdlc Report file to .Resx Resource file ?

$
0
0

I have a small project in VS2010.In that project I have one resource file called MyResources.resx. Now Iam using this MyResources.resx file to store the images required in my project. Also I have one report called REPORT1.rdlc. My Intention is to add that report file to that MyResources.resx resource file. Is it possible to access the report from that resouce file ?

From the below example, I stored Thatha.jpg image file in MyResources.resx. and accessed.

ResourceManager^ rm = gcnew ResourceManager("NewTest_EmbedRpt.MyResources", GetType()->Assembly);
pictureBox1->Image = safe_cast<Image^>(rm->GetObject("Thatha"));

Same way is it possible to store that Report1.rdlc in resources and can access?
Any codes and ideas will be very helpful.

Note: In c#  BuidAction property is available to set the Report1.rdlc as EmbeddedResource. 

Thanks for the guidances.


U.PARANTHAMAN

Minimum Windows version for v120 platform toolset

$
0
0

Hi.

What minimum version of Windows (WINVER, _WIN32_WINNT etc.) is supported by v120 platform toolset? As I understood, it doesn't support Windows XP (0x0501). Need to refactor code after migrating from v110_xp. Windows Vista (0x0600) or Windows Server 2003 (0x0502)?

Marian

Does Graphics.DrawDriverString support the drawing of 4-byte UTF-16 characters?

$
0
0

Graphics.DrawDriverString cannot draw 4-byte (such as [𣱿]) characters correctly.
Our project is developed by VS2010, and the Character Set is [Unicode Character Set].

//sample test code as follows:

#include <gdiplus.h>
using namespace Gdiplus;
//class member for initialize Gdiplus
ULONG_PTR            m_gdiplusToken;
GdiplusStartupInput    m_gdiplusStartupInput;
//initialize Gdiplus
Gdiplus::GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL);

/// <summary>
/// test function for both display and printing
/// </summary>
/// <param name=' pDC '></param>
/// <param name=' fTop '>the top position for drawing</param>
void CPage::MyCharacterTest(CDC* pDC, float fTop)
{
    StringAlignment eVAlign = StringAlignmentCenter;
    Graphics gs(pDC->GetSafeHdc(), FALSE);
    //m_strFontName = _T("Times New Roman")//_T("MS Pゴシック")
    Gdiplus::Font oFont(m_strFontName, 18.0f, FontStyleRegular, UnitPixel);
    StringFormat oFormat;
    oFormat.SetTrimming(StringTrimmingWord);
    oFormat.SetFormatFlags(StringFormatFlagsMeasureTrailingSpaces | StringFormatFlagsDisplayFormatControl);
    oFormat.SetAlignment(StringAlignmentNear);
    oFormat.SetLineAlignment(eVAlign);
    SolidBrush oMyBrush(Color(255, 255,0,0));
    RectF rcRect(20, fTop + 40, 200.0f, 40.0f);
    PointF oPtStart1(20, fTop + 30 + 40 * 2);
    PointF oPtStart2(20, fTop + 30 + 40 * 3);

    CString strContent = _T("DrawString:123𣱿456");
    CString strContent1 = _T("DrawDriverString1:123𣱿456");
    CString strContent2 = _T("DrawDriverString2:123𣱿456");
    TCHAR szText[100]=_T("123𣱿456");

    //DrawString: both of display and print are correct
    gs.DrawString(strContent, strContent.GetLength(), &oFont, rcRect, &oFormat, &oMyBrush);    
    //DrawDriverString: display is correct; but,
    //print by virtual printer (Microsoft XPS Document Writer) will lost the last character “6”
    //print by physical printer, it will lost the last character “6” and show unknown character
    gs.DrawDriverString((UINT16*)(LPCTSTR)strContent1,
             strContent1.GetLength(),
             &oFont,
             &oMyBrush,
             &oPtStart1,
             DriverStringOptionsCmapLookup | DriverStringOptionsRealizedAdvance,
             NULL);
    gs.DrawDriverString((UINT16*)(LPCTSTR)strContent2,
            -1,
             &oFont,
             &oMyBrush,
             &oPtStart2,
             DriverStringOptionsCmapLookup | DriverStringOptionsRealizedAdvance,
             NULL);
}

Through the test under different language's operating system(English OS, Japanese OS, Chinese OS), I find the display result("123𣱿123") draw by DrawString is absolutely right, as well as the result by Microsoft XPS Document Writer and physical printer if use the API DrawString. On the other hand, if we use the API DrawDriverString, the character "𣱿"will not show correctly, at the same time, the result by virtual printer and physical will be more strange(the last character "3"can not be print out, print out show a strange character).

I wonder if the DrawDriverString supported drawing characters outside the BMP(Basic Multilingual Plane) for printing, such as above [𣱿] a 4-byte character.


Visual C++ Debugging Error - wuser32.pdb not loaded

$
0
0

I have made a form (GUI) in Visual C++ & while debugging it step by step, I got the following error, which stopped further debugging of the code.

The screenshot of the error is shown below.

How to solve this?


unexpected operand size in inline assembler

$
0
0

Hello,

I am trying to use the inline assember without success. My goal is to observe outputs of several assembly instructions (and, sub, add) depending on different input size (width ?) and signedness.

For this I wrote the following:

bool o test_and(uint32_t i1, uint32_t i2)
{
    uint32_t eflag;
    {
        __asm movzx eax, i1;
        __asm and eax, i2;
        __asm pushfd;
        __asm pop eflag;
    }
    return (eflag & 1U<<6 ? 1 : 0); /* pour observer le Carry Flag */
}

However the movzx instruction does not load the 32 bits of i1 into eax, but rather its 8 first bits...which is not what I was expecting given that i1 is defined as a 32 bit unsigned integer.

How shall do, provided that I have a small template "mecanic" behind in order to select automatically the types of i1 and i2 (signed versus unsigned, 8, 16 or 32 bits).

I have to confess I don't know assembler quite well, and it is my first steps with inline assembler.    

A.G.

Comparing boost::scoped_ptr and std::auto_ptr

$
0
0

Hi , i was doing a little reading on scoped pointers and i came to aline which stated

"Since a scoped pointer simply stores and solely owns an address, the implementation ofboost::scoped_ptr is less complex than std::auto_ptr. boost::scoped_ptr should be preferred if transfer of ownership is not required. In these situations, it may be a better choice thanstd::auto_ptr to avoid inadvertent transfer of ownership."

Now what does transfer of ownership mean ?? Could anyone give an example of what transfer of ownership means ??

and i also came along scoped boost scoped array whats the difference between Scoped Array and boost scoped Pointer.

What i know is that boost scoped array is merely used as a pointer to store the address of Arrays that we have created.. 

A little bit of background and more information would be helpful..


A candle loses nothing by lighting another candle.

Visual Studio 2008 express compatability with windows 7

$
0
0

Hi,

Do you guys know if Windows 7 (32 bit) will run with visual studio express 2008?

I know vs08 isn't supported anymore but we have an application that can only run on vs<=08, so there is nothing we can do.

Thanks

How to create Windows Forms Application in VS C++ 2013 RC?

$
0
0
In VS C++ 2010, the template is easy to find: New Project -> Visual C++ -> CLR -> Windows Forms Application.
In VS C++ 2013 RC, New Project -> Visual C++ -> CLR doesn't have Windows Forms Application template.
The following link doesn't help because it's for C#, only.
http://msdn.microsoft.com/en-us/library/vstudio/dd492132(v=vs.120).aspx
Is this a bug (or a design flaw) in VS 2013 Release Candidate?
Since this is only an "RC", it's a "candidate" for release, and maybe the final release will correct this defect?
Is there a way to manually create a Windows Forms Application?

Compiler cannot distinguish different lambda function parameters

$
0
0

I was wondering why this code does not compile:

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

bool Run(std::function<bool()> f) { return f(); }
void Run(std::function<void()> f) { f(); }

int _tmain(int argc, _TCHAR* argv[])
{
  Run([] { return true; });
  Run([] {});
  return 0;
}

Both calls to Run() trigger C2668: 'Run' : ambiguous call to overloaded function.

If I define overloaded functions that differ only in their return types then the compiler can't figure out which one to pick - granted.

The parameters to Run() are implicitly augmented to this notation:
    Run([] (void) -> bool { return true; });
    Run([] (void) -> void {});

So I assumed that the template "std::function" would expand to something like "__mangling_void_bool_mangling__" in the first case and to something like "__mangling_void_void_mangling__" in the second case; effectively defining two different types for paramter f in the overloaded versions of Run().

But the compiler seems to treat the std::function parameter f like a plain old void* pointer without any type information.

Is that correct?

C++ templates function argument deduction

$
0
0

In relation to this snippet:

#include <iostream>
#include <type_traits>

template<typename T>
void f(T t)
{
    static_assert(std::is_same<T, const int>::value, "T != const int");
    std::cout << t << '\n';
}


int main()
{
    void(*pf)(int) = f;
    pf(1000);
}

the static_assert doesn't fire because the declaration

void(*pf)(int) = f;

seems to instantiate the function f with T = int. I'd like to know which rule in the C++11 Standard supports this instantiation.

Note that if you replace int by const int in this declaration, thestatic_assert continues to fire, i.e., the compiler instantiates a functionf with T = int again. Why?


File Path length

$
0
0

Is there any limitation of file path length ?

If copied long path file name when minifilter driver is running, it's failed.

printer print a ¢

$
0
0

#include

<iostream>// printer print  on paper


using

namespace std;


#include

<fstream>



#using

<System.dll>


#using

<System.Windows.Forms.dll>


#using

<System.Drawing.dll>


using

namespace System;


using

namespace System::IO;


using

namespace System::Drawing;


using

namespace System::Drawing::Printing;


using

namespace System::Windows::Forms;



public

refclass PTM{


private

: Font^ printFont; StreamReader^ streamToPrint;


static

String^ filePath;


public

: PTM() { Printing(); }


private

: // The PrintPage event is raised for each page to be printed.


  

void pd_PrintPage( Object^/*sender*/, PrintPageEventArgs^ ev ) {

     

float linesPerPage = 0;

     

float yPos = 0;

     

int count = 0;

     

float leftMargin = (float)ev->MarginBounds.Left;

     

float topMargin = (float)ev->MarginBounds.Top;

      String^ line =

nullptr;

     

// Calculate the number of lines per page.


linesPerPage = ev->MarginBounds.Height /

printFont->GetHeight( ev->Graphics );

// Iterate over the file, printing each line.


while

(count<linesPerPage && ((line=streamToPrint->ReadLine()) !=nullptr)){

     yPos = topMargin + (count * printFont->GetHeight( ev->Graphics ));

ev->Graphics->DrawString(line,printFont,Brushes::Black,leftMargin,yPos,


gcnew

StringFormat ); count++; }

     

// If more lines exist, print another page.


if

(line != nullptr) ev->HasMorePages =true;else ev->HasMorePages = false;}


public

: // Print the file.


void

Printing() {


try

{ streamToPrint = gcnew StreamReader("Pcs" );


try

{ printFont = gcnew System::Drawing::Font("Times New Roman",12 );

      PrintDocument^ pd =

gcnew PrintDocument;

pd->PrintPage +=

gcnew


PrintPageEventHandler(

this, & PTM::pd_PrintPage );

pd-> DefaultPageSettings->Margins->Left = 5 ;

pd-> DefaultPageSettings->Margins->Right = 5 ;

pd-> DefaultPageSettings->Margins->Top = 10 ;

pd-> DefaultPageSettings->Margins->Bottom = 10 ;

pd->Print(); }

// Print the document.


finally

{ streamToPrint->Close(); }

String ^ c =

gcnew String("Pcs"); File::Delete(c); }


catch

( Exception^ ex ) { MessageBox::Show( ex->Message ); }}


static

void Main() {

     

array<String^>^args = Environment::GetCommandLineArgs();

      String^ sampleName = args[ 0 ];


if

( args->Length != 2 ) {

   Console::WriteLine(

"Usage: {0} <file path>", sampleName );return; }

    filePath = args[ 1 ];

gcnew PTM; }};



int

main(){

ofstream out(

"Pcs");// printer print  on paper, why and how to fix it ?



out<<

""<<""<< ''<<""<< "\233"<<""<< '\233'<<endl;

out.close();  PTM();

cout<<

"\n\n do it a diferent way";



//fstream diferent;



fstream diferent(

"PCS", ios::out | ios::binary);__int8 A2='\233', A3='';

diferent.write((

char *)&"",sizeof"");

diferent.write((

char *)&A2,sizeof A2);

diferent.write((

char *)&A3,sizeof A3);

diferent.write((

char *)&"\233",sizeof"\233");

diferent.close(); PTM();

cout<<

"Printer print \233 on paper ?";

cout<<

"\n\n"; system("pause");return 0; }

My application steals focus from other application

$
0
0
My application is VC++ MFC MDI application. When i run my application on Windows 7, it steals focus from other application whenever a new document is created. In Win XP, I had not faced this issue. Any idea how do I stop my application from stealing focus from other application.

How add a banner at the top of the propertysheet (wizard style) in mfc

$
0
0

Hi,

I created a proeprtysheet of wizard style using mfc, the problem is I should add a banner to the top of the

propertysheet. So,I added OnPaint() method to a class "CInstallerWizard" which is dervied from CPropertySheet ,

but this piece of code is unable to add the bitmap (banner ) to the top of the propertysheet.

void CInstallerWizard::OnPaint() { CPaintDC dc(this); // device context for painting CBitmap bmp_PropSheet,*pOldBmp; CDC memdc; CRect rect; //Load bitmap resource bmp_PropSheet.LoadBitmap(IDB_BITMAP_DRIVER_LOGO); //Create compatible memory dc memdc.CreateCompatibleDC(&dc); //Select bitmap into the DC pOldBmp = memdc.SelectObject(&bmp_PropSheet); //Copy (BitBlt)bitmap form memory dc to the screen dc GetClientRect(&rect); dc.BitBlt(10,rect.bottom - 22,88,16,&memdc,0,0,SRCCOPY); memdc.SelectObject(&bmp_PropSheet); //Should not call CPropertySheet::OnPaint() }

Again I tried doing like this,

Note:m_DriverInstallStatus object for the class derived from propertysheet.

m_DriverInstallStatus.m_psp.dwFlags |= PSP_USEICONID;
m_DriverInstallStatus.m_psp.pszIcon = MAKEINTRESOURCE(IDI_ICON_PRINTER);

But this also could not get any change to the propertysheet.

Can anyone please let me know how can I achieve this.

Thanks in advance.


How to set CFB-128 using Microsoft CryptoAPI?

$
0
0

I am using MS_ENH_RSA_AES_PROV provider with PROV_RSA_AES provider type. I have selected CALG_AES_128 block cipher algorithm with CRYPT_MODE_CFB cipher mode. I would like to set KP_MODE_BITS key parameter to 128, but calling CryptSetKeyParam() by passing value greater than 64 always returns with NTE_BAD_DATA (0x80090005L).

How can I set CFB-128 using CryptoAPI? Thanks.

VS 2013 Pro C++ with 2010 toolset - atlimage missing

$
0
0

So it happened that I am a proud owner of VS 2013 Pro. Unfortunately currently I am working with project that requires v100 toolset. I thought that installing VS 2010 Express would match that requirements, but as it turns out VS 2010 Express does not have ATL (atlimage.h not found). 

My question is: can I somehow use atl that is installed with VS 2013 Pro? Alternatively is there a way do add atl to VS 2010 Express when I already bought 2013 and buying additionally 2010 seems waste of money?

I don't think I can not simply change toolset and/or change include paths as projects in this solution are hooked up to git repository and there are other people working on that projects using VS 2010.

Any advice is appreciated!

Thanks.

error C1189: #error : DAO Database classes are not supported for Win64 platforms: While upgrading platform from 32 bit to 64 bit VC++

$
0
0
I have project in vc++. I am using VS2010 32 bit, Windows 7 64 bit, Supported components to compile 64 bit projects are installed. I am able to compile the project with 32 bit platform. I want to upgrade the platform to 64 bit. I modified the platform configuration to 64 bit (as per :http://msdn.microsoft.com/en-us/library/9yb4317s%28v=vs.100%29.aspx) and trying build the solution and getting the error.

error C1189: #error :  DAO Database classes are not supported for Win64 platforms    c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxdao.h    15    1    ProjectName

Is there any 64 bit dao class libraries that I can install and build the solution?

Is there any configuration I am missing?

How can I build the solution?

SSD Configuration?

$
0
0

Hi Folks:

   Solid State Drives?  Is this the right forum?  Isn't that hardware and this forum is about... C++? 

   Yea, this is the right forum. 

   I've been developing projects with 100K plus lines of C++ code on my tired 6 or 7 year old PC.  A full compile can take over 15 minutes! 

   I'm in the market for a new PC.  I want a rocket. 

   Just a new I7 processor and new fast drive will get me far, but I want more. 

   So, I'm looking at solid state drives, but I'm not sure what I want, or how to configure one to boost massive C++ compiles. 

   What SSDs are you guys and gals using? 

   How big?

   What's on your SSD, what's in your hard drive? 

   System and Visual Studio on the SSD? 

   C++ Projects on the SSD?

   I'll want anything sensitive, like my code, on a Truecrypt encrypted partition.  In case my shiny new PC grows legs and walks out the door. 

   Any ideas on how to move forward are appreciated. 

   Thanks
   Larry



Viewing all 15302 articles
Browse latest View live


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