|
//======================== Member variables ===========================//
CFont m_Font;
CEdit m_Eidt;
//====================== Some where ===================================//
m_Edit.Create(WS_VISIBLE|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL,
CRect(100,100,500,150),
this,
8888);
//============================== Set the font of a control ===================//
LOGFONT lf;
//===== Initialize the LOGFONT structure =============//
lf.lfHeight = 0 ;
lf.lfWidth = 0 ;
lf.lfEscapement = 0 ;
lf.lfOrientation = 0 ;
lf.lfWeight = 400 ;
lf.lfItalic = FALSE ;
lf.lfUnderline = 0 ;
lf.lfStrikeOut = 0 ;
lf.lfCharSet = ANSI_CHARSET ;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS ;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS ;
lf.lfQuality = DEFAULT_QUALITY ;
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
lstrcpy(lf.lfFaceName, "CommercialScript BT") ;
//============= Set the font of the control ===============//
m_Font.CreateFontIndirect(&lf);
m_Edit.SetFont(&m_Font);
///// The end /////
|
|
|
|
|
The above code change the font in an edit box not color
nave
|
|
|
|
|
Using Visual C++ (6.0) MFC, there is more than one way. If you search for "CEdit background", you will find 17 possible answers (see "Change the Background Color of an MFC Edit Control" ID: Q117778).
At the current time I am studying VB.Net (no choice) and in that you just call "sender.BackColor = color" ("sender" is an object derived control), which probably applies to C# as well (through the framework).
You could derive a class from a CEdit control and override the "OnEraseBkgnd" method, but there should be a better way.
That is the best I can do at the moment.
INTP
Every thing is relative...
|
|
|
|
|
|
Where is the most appropriate place to save the placement of the MDI Frame window when the app is closing?
CWinApp->ExitInstance?
FrameWnd->DestroyWindow?
FrameWnd->OnCmdMsg?
Rich
|
|
|
|
|
I use the following so it gets stored on a per user basis...
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
WINDOWPLACEMENT windowPlacement;
GetWindowPlacement(&windowPlacement);
AfxGetApp()->WriteProfileBinary("Settings","Window",(BYTE*)&windowPlacement,
sizeof(WINDOWPLACEMENT));
CMDIFrameWnd::OnClose();
}
BOOL CYourApp::InitInstance()
{
// Other stuff removed for clarity
// The main window has been initialized, so show and update it.
// Also get previous settings from registry for position
UINT unSize;
WINDOWPLACEMENT * pWindowPlacement;
if (GetProfileBinary("Settings","Window",(LPBYTE*)&pWindowPlacement,&unSize)) {
pMainFrame->SetWindowPlacement(pWindowPlacement);
} else {
pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
}
pMainFrame->UpdateWindow();
return TRUE;
}
|
|
|
|
|
Thanks, that helps a lot!
|
|
|
|
|
Hi all
Turn Off monitor??????
yes , how to Turn Off monitor by programming i need any commands using c/c++ & MFC or API ??
i want to turn it off as the windows do in the power save??
any tips thx
|
|
|
|
|
|
Send Message WM_SYSCOMMAND with SC_MONITORPOWER to app self
|
|
|
|
|
I know how to change an icon, I was just wondering if anybody knows how to generate new icons at runtime, or ideally how to create a new icon identical to the previous but with different colours? Alternatively, is it possible to change display colours of an icon without creating a new one?
When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!
|
|
|
|
|
You can create a bitmap using the CreateBitmap API. Then you can use GDI to draw to it. Then you add it to the image list of the tree control using the ImageList_Add function. MFC has wrappers for there APIs.
Steve
|
|
|
|
|
CImageList *m_ImageTree;
TV_INSERTSTRUCT TreeItem;
HTREEITEM hTreeItem;
CBitmap bit;
m_ImageTree = new CImageList();
m_ImageTree->Create(15,15, ILC_COLORDDB,0,0);
TreeItem.hParent = TVI_ROOT;
TreeItem.hInsertAfter = TVI_LAST;
TreeItem.item.mask = TVIF_TEXT | TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
TreeItem.item.pszText = _T("TEST");
TreeItem.item.lParam = 0;
TreeItem.item.iImage=0;
TreeItem.item.iSelectedImage=0;
hTreeItem = m_Tree1.InsertItem(&TreeItem);
bit.LoadBitmap(IDB_BITMAP1);
m_ImageTree->Add(&bit,RGB(255,0,255));
m_Tree1.SetImageList(m_ImageTree, LVSIL_NORMAL);
|
|
|
|
|
and you can replace
HBITMAP hBmp = (HBITMAP)LoadImage(NULL,"c:\\a.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
bit.Attach(hBmp);
instead
bit.LoadBitmap(IDB_BITMAP1);
|
|
|
|
|
I am using DLL in one project. I built two DLLs and conresponding libs, but one dll works well and the other does not. That is one dll exports functions correctly, the other produces link error 2019. I checked the dlls by dumpbin, and found the export functions in the right dll look like "FileWrapper_Close" same as the defination of the function, but the other functions in the wrong dll look like "_CopyResamplerState@4", additional letters '@', '4' and '_' added to the name. I built the two dlls in the same way, I could not figure out why they are different. Thanks for your help.
|
|
|
|
|
You've discovered the "name mangling" done by the C++ compiler. If you want your DLL functions to be exported with their names the same way they are defined in code, there are a couple of options.
My favorite way is to define my exports with the extern "C" declaration. For example:
extern "C"
{
BOOL Function(INT Param)
{
// Do stuff
}
}
|
|
|
|
|
|
Hi,
i am trying to solve the following problem.
I got an Dialog and when i close it the coordinates will be saved in registry.
Now if you use Multi-Screen and you close the dialog for example on X: 2400 and Y: 1000 and you remove the second monitor, you have an "out of range" i call it. Now I want to check for all cases,
multiscreen left-side, right-side, or top-on-top (xcuse my englisch).
How can I get the coordinates e.g. on left-side situation ( X must be like -1340)
Using VS 6.0 SP 5
thx a lot
|
|
|
|
|
|
Does not work !!! If I have coordinates which lie out of the visible range of BOTH dipslays for example, the dialog will still be loaded outside my visible range.
One solution is I thougth to get all four Window Edges, left, right, top and bottom (no rectanlge because the displays could be arrangend as L-Form).
anyway, thank you very much for your response
|
|
|
|
|
Michael Dunn has probably given you the simplest, easiest solution!
If you choose to follow the harder solution, keep in mind that the monitors do no have to be arranged to form a rectangle. If you have 3 monitors, they could be arranged in an "L" configuration, so monitor 2 is above monitor 1 and monitor 3 is to the right of monitor 1.
To handle this, look at using enumDisplayMonitors() callback function to determine the coordinates of every monitor, etc.
|
|
|
|
|
This works fine ! Thank you
|
|
|
|
|
Well, now you've just annoyed me!
How did you get that working so quickly? When I decided I needed to use enumDisplayMonitors(), I think it took me a couple of days to get anything working!
|
|
|
|
|
Hello.
I am working on a console C project under VS.net. I want to measure execution times between lines of code. I have looked over the documentation to try to set up "ENABLE PROFILING" on my project. I dont understand how to set it up. Can anyone help me out? Or point me to some examples where it is used.
Jerry
|
|
|
|
|
Hi.........
I noticed that it remains extremely hard to plot by using VC++ 6 itself for readind data and plotting............
Moreover no such sources available, just hybrids!
If someone has one....... TIP TOP,
I would wecome to receive it for personal knowledge!
Thanks..
example of file:(txt file)
Typical header:Solvers, or optimizers, are software tools that help users find the best way to allocate scarce resources.
1 5.258
2 -8.548103675
3 -7.686156375
4 -9.859503638
5 4.211616105
6
.
.
.
with comments With so many domestic distractions, working from home can tempt even the most diligent wor........
Thanks
|
|
|
|