Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

C++ MessageBoxes

DarkEvilOneDarkEvilOne Member Posts: 5
I want to make a message box show a few fixed strings and a few class members but when i tried the following code i got told .dwHeight and .dwWidth need a type or something on the left which is really confusing me..

MessageBox(NULL, "Width: " && ddsDesc.dwWidth & "
Height: " && ddsDesc.dwHeight, "Compatible display mode", MB_OK);

The program is a simple test program to enumerate display modes using direct draw 7. The .dwWidth and .dwHeight are both DWORDs.

If anyone can tell me what i've done wrong then please do! If you need more code to work out whats wrong ask for it and i'll tell you

Thanks!

Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    [b][red]This message was edited by stober at 2003-3-6 7:12:33[/red][/b][hr]
    : MessageBox(NULL, "Width: " && ddsDesc.dwWidth & "
    Height: " && ddsDesc.dwHeight, "Compatible display mode", MB_OK);
    :

    [red] I know this is a REALLY old thread, but I'll answer it anyway just in case someone else has stumbled across the same problem.

    You can't concantinate strings that way -- C/C++ does not work like VB or other languages. You have to format the string before sending it to MessageBox(). There are a couple ways to do that. I'll illustrate the simplest, C, method.

    [code]
    char buffer[126];
    sprintf(buffer,"Width: %d
    Height: %d",ddsDesc.dwWidth, ddsDesc.dwHeight);

    MessageBox(NULL,buffer,"Compatible display mode", MB_OK);
    [/code]





  • Andre YoungAndre Young USAMember Posts: 0

    _____ \ http://forcoder.org \ free ebooks and video tutorials about [ PHP Visual Basic JavaScript Go Delphi Scratch MATLAB C Visual Basic .NET Ruby PL/SQL C# R Perl C++ Python Java Swift Objective-C Assembly Clojure COBOL Erlang Prolog Bash D Dart F# Apex ABAP Fortran Alice Transact-SQL FoxPro VBScript Kotlin LabVIEW Awk Rust Scheme Hack Crystal Scala Julia Ada SAS Lisp Logo ML Lua ] ___________

Sign In or Register to comment.