I am developing my project in C. On windows-7 I am using DosBox to implement my code. On compile my project doesn't show any error. But when I run my project its simply display the following line on output screen.
bgi error graphics not initialized use initgraph
Here's my code:
void firstscreen()
{
int gm=DETECT;
initgraph(&gm,&gm,"");
floodfill(300,230,RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
setcolor(BLUE);
sound(1345);
outtextxy(100,40,"S.A.JAIN COLLEGE ");
outtextxy(190,90,"AMBALA CITY");
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
setcolor(GREEN);
outtextxy(210,230,"PROJECT REPORT ");
outtextxy(290,265,"ON ");
outtextxy(240,300,"MOBILE SHOP");
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
setcolor(CYAN);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
outtextxy(160,400,"Developed By - MAHI");
setcolor(BLUE);
settextstyle(1,HORIZ_DIR,1);
outtextxy(240,440,"Press any key to enter in the program........");
nosound();
getch();
closegraph();
}
void showroom()
{
int gm=DETECT;
initgraph(&gm,&gm,"");
floodfill(300,230,RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
setcolor(BLACK);
sound(1345);
outtextxy(240,25,"SHOWROOM");
outtextxy(240,50,"^^^^^^^^^");
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
setcolor(RED);
outtextxy(10,85,"Model No Price(Rs\-) Color Wranty");
settextstyle(TRIPLEX_FONT,HORIZ_DIR,2);
setcolor(GREEN);
outtextxy(10,125, "X2-01 2300 WHITE 1 YEAR");
outtextxy(10,155,"X3-02 7800 BLACK 1 YEAR ");
outtextxy(10,185,"E5 4800 BLACK 1 YEAR");
outtextxy(10,215,"3110 3800 BLACK 1 YEAR ");
outtextxy(10,245,"7210 5200 BLACK 1 YEAR");
outtextxy(10,275,"5233 5800 BLACK 1 YEAR ");
outtextxy(10,305,"N70 8000 BLACK 1 YEAR");
outtextxy(10,335,"N72 8800 BLACK 1 YEAR");
outtextxy(10,365,"N95 10500 BLACK 1 YEAR");
setcolor(BLUE);
settextstyle(1,HORIZ_DIR,1);
outtextxy(440,440,"Press enter......");
nosound();
getch();
closegraph();
}
On SO I saw similar question on this but no answer is accepted by the owner. And also when I try those solutions still same problem. Most of the answers suggest to use path of BGI library. Path of BGI library in my computer.
C:\\TurboC++\\Disk\\TurboC3\\BGI
In my code I am setting path like follow-
int gm = DETECT;
initgraph(&gm,&gm,"C:\\TurboC++\\Disk\\TurboC3\\BGI");
But not working still same problem. Please help me to solve this. Thanks in advance.
Recently I have similar problem. To solve this copy EGAVGA.BGI from BGI folder and paste into BIN folder.
Hope it works.
Related
There are a number of questions and answers about setting wallpapers programmatically on multi-monitor setups in Windows, but I'm asking specifically for Windows 10 (and maybe Windows 8) because it seems to work differently from all the explanations I found.
Raymond Chen has an article "How do I put a different wallpaper on each monitor?" (https://devblogs.microsoft.com/oldnewthing/?p=25003), also quoted in Monitors position on Windows wallpaper. The core concepts is that Windows places the top-left corner of the provided bitmap at the top-left corner of the primary monitor, and wraps around to fill any desktop space to the left and/or above that. I understand that, I wrote a little program using that knowledge, and it works beautifully in Windows 7.
How it works: I create a bitmap that conceptually covers the whole desktop space, as the user sees it. I draw the contents of each monitor to that bitmap in its appropriate position (the program is written in C++ using VCL, but the principle remains the same in other programming environments):
TRect GetMonitorRect_WallpaperCoords(int MonitorNum)
{
Forms::TMonitor *PrimaryMonitor = Screen->Monitors[0];
Forms::TMonitor *Monitor = Screen->Monitors[MonitorNum];
// Get the rectangle in desktop coordinates
TRect Rect(Monitor->Left, Monitor->Top, Monitor->Left + Monitor->Width, Monitor->Top + Monitor->Height);
// Convert to wallpaper coordinates
Rect.Left += PrimaryMonitor->Left - Screen->DesktopLeft;
Rect.Top += PrimaryMonitor->Top - Screen->DesktopTop;
Rect.Right += PrimaryMonitor->Left - Screen->DesktopLeft;
Rect.Bottom += PrimaryMonitor->Top - Screen->DesktopTop;
return Rect;
}
std::unique_ptr<Graphics::TBitmap> CreateWallpaperBitmap_WallpaperCoords()
{
std::unique_ptr<Graphics::TBitmap> Bmp(new Graphics::TBitmap);
Bmp->PixelFormat = pf24bit;
Bmp->Width = Screen->DesktopWidth;
Bmp->Height = Screen->DesktopHeight;
// Draw background (not that we really need it: it will never be visible)
Bmp->Canvas->Brush->Style = bsSolid;
Bmp->Canvas->Brush->Color = clBlack;
Bmp->Canvas->FillRect(TRect(0, 0, Bmp->Width, Bmp->Height));
for (int MonitorNum = 0; MonitorNum < Screen->MonitorCount; ++MonitorNum)
{
TDrawContext DC(Bmp->Canvas, GetMonitorRect_WallpaperCoords(MonitorNum));
DrawMonitor(DC);
}
return Bmp;
}
(The draw context uses a coordinate translation rect so that the code int DrawMonitor function can draw in a rectangle like (0, 0, 1920, 1080) without having to wonder where in the full bitmap it is drawing, and with a clip rect so that DrawMonitor can not accidentally draw outside of the monitor it's drawing on).
Then I convert that bitmap to an image that will properly wrap around when placed at the top-left corner of the primary monitor (as Raymond Chen describes in his article):
std::unique_ptr<Graphics::TBitmap> ConvertWallpaperToDesktopCoords(std::unique_ptr<Graphics::TBitmap> &Bmp_WallpaperCoords)
{
std::unique_ptr<Graphics::TBitmap> Bmp_DesktopCoords(new Graphics::TBitmap);
Bmp_DesktopCoords->PixelFormat = Bmp_WallpaperCoords->PixelFormat;
Bmp_DesktopCoords->Width = Bmp_WallpaperCoords->Width;
Bmp_DesktopCoords->Height = Bmp_WallpaperCoords->Height;
// Draw Bmp_WallpaperCoords to Bmp_DesktopCoords at four different places to account for all
// possible ways Windows wraps the wallpaper around the left and bottom edges of the desktop
// space
Bmp_DesktopCoords->Canvas->Draw(Screen->DesktopLeft, Screen->DesktopTop, Bmp_WallpaperCoords.get());
Bmp_DesktopCoords->Canvas->Draw(Screen->DesktopLeft + Screen->DesktopWidth, Screen->DesktopTop, Bmp_WallpaperCoords.get());
Bmp_DesktopCoords->Canvas->Draw(Screen->DesktopLeft, Screen->DesktopTop + Screen->DesktopHeight, Bmp_WallpaperCoords.get());
Bmp_DesktopCoords->Canvas->Draw(Screen->DesktopLeft + Screen->DesktopWidth, Screen->DesktopTop + Screen->DesktopHeight, Bmp_WallpaperCoords.get());
return Bmp_DesktopCoords;
}
Then I install that bitmap as a wallpaper by writing the appropriate values in the registry and calling SystemParametersInfo with SPI_SETDESKWALLPAPER:
void InstallWallpaper(const String &Fn)
{
// Install wallpaper:
// There are 3 name/data pairs that have an effect on the desktop wallpaper, all under HKCU\Control Panel\Desktop:
// - Wallpaper (REG_SZ): file path and name of wallpaper
// - WallpaperStyle (REG_SZ):
// . 0: Centered
// . 1: Tiled
// . 2: Stretched
// - TileWallpaper (REG_SZ):
// . 0: Don't tile
// . 1: Tile
// We don't use the Wallpaper value itself; instead we use SystemParametersInfo to set the wallpaper.
// The file name needs to be absolute!
assert(Ioutils::TPath::IsPathRooted(Fn));
std::unique_ptr<TRegistry> Reg(new TRegistry);
Reg->RootKey = HKEY_CURRENT_USER;
if (Reg->OpenKey(L"Control Panel\\Desktop", false))
{
Reg->WriteString(L"WallpaperStyle", L"1");
Reg->WriteString(L"TileWallpaper", L"1");
Reg->CloseKey();
}
SystemParametersInfoW(SPI_SETDESKWALLPAPER, 1, Fn.c_str(), SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
}
But when I test it in Windows 10, it doesn't work properly anymore: Windows 10 puts the wallpaper completely in the wrong place. Seeing as other people have asked questions about multi-monitor wallpapers in the past, I'm hoping there are people with experience of it on Windows 10.
As far as I can see, Windows 10 places the top-left corner of the provided bitmap at the top-left corner of the desktop space (by which I mean the bounding rectangle of all monitors), instead of the top-left corner of the primary monitor. In code, that means: I leave out the ConvertWallpaperToDesktopCoords step, and then it works fine as far as I can see.
But I can't find any documentation on this, so I don't know if this is officially explanation of how Windows 10 does it. Use with care. Also I don't know when this different behavior started: in Windows 10, or maybe earlier in Windows 8.
Since I don't have any of the mentioned phones with Windows 10 Mobile, can someone, who have Lumia 950 or 950 XL , run the following few lines of code in blank UWP application project to get the Scale value out of this device (to figure out effective resolution eventually):
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
// ### snipped start ###
var qualifiers = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues;
string scale;
if (qualifiers.TryGetValue("Scale", out scale))
{
System.Diagnostics.Debug.WriteLine(scale);
}
// ### snipped end ###
}
}
Please post the integer number from the output window as an answer - will be much appreciative!
PS. Suspecting that it should be 400 for 950 and 450 for 950 XL, but would like to be sure.
OK, in case anybody will look for it later - the scale is 400 for Lumia 950, thanks to colleague, who bought it recently.
I'm working on a custom Plymouth splash for Kubuntu. I'm attempting to make an image rotate as the system is loading. I have tested it using both reboots and the X11 plugin and have been unsuccessful in both. Here's the .script file:
spiral_image = Image("Splash.png");
spiral_sprite = Sprite(spiral_image);
spiral_sprite.SetX(window.GetWidth() /2 - spiral_image.GetWidth() /2);
spiral_sprite.SetY(window.GetHeight() /2 - spiral_image.GetHeight() /2);
fun refresh_callback ()
{
time++;
theta = time / 100;
spiral_sprite.Rotate(theta);
}
Plymouth.SetRefreshFunction (refresh_callback);
You need to rotate the image, not the sprite:
fun refresh_callback () {
time++;
theta = time / 100;
spiral_sprite.SetImage( spiral_image.Rotate(theta) );
}
As per official documentation, in case anyone finds this question before they manage to find Plymouth documentation.
(Extra notes, slightly off-topic: Documentation says that default text colour is white. Don't count on that too much, it's black.)
I'm trying to draw a CSpinButtonCtrl as a buddy of an edit box in Windows 7. When my CEdit window is 12 dialog units high, the spin buttons are scaled really badly and the top border is clipped off.
This looks pretty ugly. How can I get around this, or must I restrict my CEdit controls to be 14 dialog units high?
My controls are declared thusly:
EDITTEXT IDC_LOWER_EDIT,51,20,63,12,ES_MULTILINE | ES_WANTRETURN,WS_EX_RIGHT
CONTROL "",IDC_LOWER_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,104,17,11,12
I've tried resizing using MoveWindow, but that doesn't help. Any ideas?
I found the code for changing the width
CWnd* pWnd = GetDlgItem( IDC_SPIN1 );
CRect rect;
pWnd->GetWindowRect( &rect );
ScreenToClient( &rect );
rect.right += 5 ; // make 5 pixels wider
pWnd->MoveWindow(&rect) ;
Put it in the OnInitDialog().
I think I would go for #2 - are you that pressed for screen space?
Another option is: leave it unattached (remove UDS_ALIGNRIGHT) and place it right next to the edit control.
I have written the following code after creating the CRichEditCtrl
// 06112010 : The following code was added to highlight the textselection in black color instead of the default blue color of CRichEditCtrl. - 1311
{
m_EditControl.SetSel(0,100);
CHARFORMAT2 cf1;
cf1.cbSize = sizeof(CHARFORMAT2);
m_EditControl.GetSelectionCharFormat(cf1);
cf1.dwMask = CFM_BACKCOLOR ;
cf1.dwEffects &= ~CFE_AUTOBACKCOLOR;
cf1.crBackColor = RGB(0,0,0);
m_EditControl.SetSelectionCharFormat(cf1);
m_EditControl.Invalidate();
}
After this I am adding text, but the selection still comes in blue color instead of Black. Could someone please tell me what I am doing wrong??
Thanks,
DeV
You can't do it using SetSelectionCharFormat, which will only reformat the selected text. What you're asking for is an owner draw rich edit control, which is going to be more work than just deriving your own custom window from CWnd and implementing your own WM_PAINT handler.