|
Hi guys!
I want to learn how to create a windows window (instead of the boring DOS prompt) so I have searched and found code for doing this.
However, I get these error messages:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 200 Borland window.cpp:
Warning W8057 window.cpp 50: Parameter 'hPrevInstance' is never used in function __stdcall Winmain(HINSTANCE__ *,HINSTANCE__ *,char *,int)
Warning W8057 windwo.cpp 50: Parameter 'szCmdLine' is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int)
Turbo Incremental Link 5.00 Copyright (c) 1997, 200 Borland
Error: Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\COX32.OBJ
The code I found that's supposed to create a windows window is the following:
window.cpp:
#include <windows.h>
#include "Resource.h"
LRESULT CALLBACK WndProc( HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam );
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
{
static TCHAR szAppName[] = TEXT( "TestApp" );
WNDCLASSEX wndclass;
HWND hWindow;
MSG msg;
wndclass.cbSize = sizeof( wndclass );
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_APPICON ) );
wndclass.hIconSm = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_APPICON_SM ) );
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndclass.hbrBackground = ( HBRUSH ) ( COLOR_WINDOW + 1 );
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if( ! RegisterClassEx( & wndclass ) )
return 0;
hWindow = CreateWindow( szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL );
ShowWindow( hWindow, iCmdShow );
UpdateWindow( hWindow );
while( GetMessage( & msg, NULL, 0, 0 ) )
{
TranslateMessage( & msg );
DispatchMessage( & msg );
}
return ( int ) msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam )
{
HDC hDC;
PAINTSTRUCT ps;
RECT rect;
switch( msg )
{
case WM_PAINT:
hDC = BeginPaint( hWindow, & ps );
GetClientRect( hWindow, & rect );
DrawText( hDC, TEXT( "This is some text, just for fun!" ), -1, & rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
EndPaint( hWindow, & ps );
return 0;
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
}
return DefWindowProc( hWindow, msg, wParam, lParam );
}
Resource.h:
#define IDI_APPICON 1000
#define IDI_APPICON_SM 1001
Recourse.rc:
#include "Resource.h"
IDI_APPICON ICON "path/to/appicon.ico"
IDI_APPICON_SM ICON "path/to/small_appicon.ico"
Can anyone help me with this?
Thanks!
Peter
|
|
|
|
|
I don't use Borland, but it looks like you need to change your entry point from "main" to "WinMain".
In visual studio, it's set under project properties->linker->advanced->entry point
or with the following command line:
/ENTRY:"main"
|
|
|
|
|
I'm working in C++ Builder and I have a round LED image that I would like to use. However Builder does not seem to accept transparent sections of the graphic and so the image appears as though it has white corners. Any thoughts on how I could get this to display as an image with a transparent background? I tried loading the image through imagelist and then set the transparent property to the white section and this worked except that the graphic then did not look like the nice quality that it use to? Any thoughts would be greatfull.
Debs*
|
|
|
|
|
if you are using a TImage just set the Transparent property to true
|
|
|
|
|
When I set TImage Transparent property to true. The part of the image that becomes transparent is not a clean cut and looks very pixelly. I believe I have to use bmp image for this transparent property to work and even with a high quality bmp I can't seem to get it to be clean transparent cut. Any other thoughts?
Deborah
|
|
|
|
|
That's one of the reasons I'm gradually moving from C++Builder to C++/CLI. I couldn't find any free controls (at least for BCB 5) that would give me proper alpha transparency.
|
|
|
|
|
Excuss my ignorance but what is C++/CLI? How are you finding the transition?? Do you have a link to more info on C++/CLI?
|
|
|
|
|
It always amazes me how people will post messages to a forum without even bothering to see which forum they're posting in! (That's a hint: you posted your original message here in the C++/CLI forum.)
I guess people just see the first three letters of the forum's name and don't bother to read the rest (I wish CP had a smiley that was less intense than , but more intense than . Maybe a little guy looking annoyed with a bit of steam coming out of his ears.)
Anyway, now that I've had my rant -- C++/CLI is Microsoft's slightly-modified version of C++ that works with their .NET framework. Here's a good introductory article: http://www.codeproject.com/managedcpp/cppcliintro01.asp[^]
|
|
|
|
|
Hi all,
i want to share data (variables defiend in dll) with my application. For this we need to use, declspec(dllimport)and declspec(dllexport) keywords.
Is there any other simple way to use the variables defined in dll.
Alternatively, if I want to to the same other than on Windows, what should i do to achieve this?
Also, can dll share variables define in my application?
Regards,
Sapan
|
|
|
|
|
ok I have made a program that simulates a petrol station (comming of cars etc..)
it is a single MFC /SDI app in witch I made 2 functions first one delets the screen and the second one draws someting on the screen. I call this functions whit a timer (every 100ms)
but there is a problem sometimes my program crashes and this is all that I get as help why it crashed
Unhandled exception at 0x7c28af6a (mfc71d.dll) in seminarska.exe: 0xC0000005: Access violation reading location 0x00000004.
So I'm sure that the problem is in this 2 functions :
becouse if I run the program whit no drawing the program never crashes:
ok here is the code for deleteing the screen:
void CseminarskaView::brisi_ekran(void)
{
CDC*tabla=GetDC();
RECT Okno;
GetClientRect(&Okno);
CBrush copic(0xffffff);
tabla->FillRect(&Okno,&copic);
}
and the code for drawing :
void CseminarskaView::risi(Bencinska postaja[])
{
//tukaj moram risati sproti
CDC* tabla=GetDC();
RECT ena;
ena.top=20;
ena.left=20;
ena.right=60;
ena.bottom=60;
int x1=0;
int x2=0;
int x3=255;
int y=25;
CString nizi;
int i ;
for (i=0;i<5;i++)
{
CString out;
out.Format("%i",i+1);
tabla->TextOut(10,y,out);
CBrush pisalo(RGB(x1,x2,x3));
tabla->FillRect(&ena,&pisalo);
ena.top=ena.top+60;
ena.bottom=ena.bottom+60;
x1=x1+60;
x2=x2+60;
x3=x3-60;
y=y+60;
//delete pisalo;
}
CString uu;
y=25;int y1=500;
for( i=0;i<5;i++)
{
for(int j=0;j<postaja[i].dolzina_vrste;j++)
{="" nizi="nizi+"" i="" ";
="" }
="" tabla-="">TextOut(80,y,nizi);
y=y+60;
nizi=" ";
uu.Format("postaja %i: %f",i,postaja[i].rezervar);
tabla->TextOut(10,y1,uu);
y1=y1+20;
}
}
can someone please help me ?
I think that the problem is CBrush but I'm not sure
becouse sometimes the program finishes Ok sometimes not
///---there is no hope for you---\\\
|
|
|
|
|
I am trying to output to the console and trying to center words on the screen. I realize that I cold assume 80 characters can be displayed across - its pretty much the absolute standard these days - but I was wondering if anyone knows a function to get the character width of the console output so that I can use that to be a little more universal in my centering function. Anyone know?
sincerely, Brett Peirce - PolerBear
To err is human; To forgive: divine.
|
|
|
|
|
Use System::Console:
int height = Console::WindowHeight;
int width = Console::WindowWidth;
Console::SetCursorPosition(5, 10);
Console::WriteLine("{0} {1}", height, width);
|
|
|
|
|
How to scroll text in dev c++ in c++ code?
please help me....I'm a computer science student....i really nedded for my project...
nayez dale
|
|
|
|
|
Be more explicit. What text, what kind of application are you using, where is the text displayed...
|
|
|
|
|
Anywhere... as long as the text will scroll. can u help me how to do that...??? I really needed in my project this comming finals....please...
nayez dale
|
|
|
|
|
http://www.codeproject.com/staticctrl/CTextScroller.asp[^]
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
Can someone tell me some windows thread example (I am jus beginger )
|
|
|
|
|
|
Worker Thread : $30
UIThread : $50
VuNic
|
|
|
|
|
I'm trying to make a lamp control with a 'LampOn' property. If the LampOn property is true, the control shows an image of a green lamp. If it's false, the control shows a red lamp. The two lamps are resources and the image is displayed as the background image of the control. Nothing else is displayed in the control.
I use this code for the LampOn property:
property bool LampOn {<br />
bool get() {<br />
return (BackgroundImage == (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"on"))));<br />
}<br />
void set(bool val) {<br />
if (val) <br />
BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"on")));<br />
else <br />
BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"off")));<br />
}<br />
}
However, if I want to use the control in a windows form, the lamp won't be usable. The property appers but I can't switch it to true. I'm pretty sure this has to do with the get code in the property. Any ideas what I did wrong?
Here the whole project (VC 2005): Click
|
|
|
|
|
Shouldn't the following:
tdlrali wrote: return (BackgroundImage == (cli::safe_cast(resources->GetObject(L"on"))));
be:
return (BackgroundImage = (cli::safe_cast(resources->GetObject(L"on")))); ?
Also, you are changing the state of the "resources" in a read-only property. Anyway, according to the original code, if the "BackgroundImage" variable is "false", the get property will return "false" and the image will be green. Thus, the image won't match the "BackgroundImages" variable's state.
-- modified at 18:17 Thursday 9th February, 2006
|
|
|
|
|
I am hosting the WebBrowser control in an application I wrote for a Windows CE .Net device. The control works properly and I am capturing events from the DWebBrowserEvents2 interface. So far, so good. I receive the DocumentComplete and NavigateComplete2 events whenever a navigation is performed. However if an error occurs (for example: Page not found, Incorrect Syntax, etc) the NavigateError event never seems to fire. Has anyone else had this issue when implementing the webbrowser control on CE?
Any help would REALLY be appreciated, as this is somewhat of a show stopper for now. If I need to elaborate or give some example code please let me know.
Thanks,
Dab
|
|
|
|
|
hey guys
i'm a novice c++ programmer and i'm currently making a program
everything works fine, but there's one slight problem...
i need to have the program output a text on-screen and i don't know how.
Let me explain, the program i want to make basically displays a text on the screen of your computer.
not the DOS prompt where it executes the program, but the screen itself.
Think of an alert-messenger that does so not by using those windows, but by just displaying the text
it needs to display.
How can I do that?
If it's no trouble, i'm also wondering if the gotoxy(x,y) (using the conio.h file) works with whatever solution to my problem you have. And how can i make that text disappear after a pre-set amount of time?
thanks for your help
regards,
peter
#include borland c++ compiler 5.5
using Windows XP;
int main()
{
cout << "Hi! I'm Peter!\n";
return 0;
}
|
|
|
|
|
When you say "on-screen", you are referring to the DeskTop? If so, you will need to create an invisible window with your visible text overlapping the DeskTop. Windows is a graphic based operating system that also allows text-based consoles to appear in graphic-based windows.
|
|
|
|
|
Why do multi threaded programs behave differently in debug mode and release mode?
|
|
|
|
|