|
I'm not so sure about if you can use a font "file" if it not is installed but if we say yes: Just add it like you add a simple bitmap as a resource. Right click the map in the tree view in VC++ and click "Import...". Then youst find the font and after that you'll be saked to write a resource type name: eg. Font. DONE!
But as I said before! I don't know if you can use uninstalled fonts...
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Ok, I give up. I am going to have to give in and ask for some help.
I am trying to change the colours of a bitmap (make it grayscale). I have got it working for 16, 24, and 32 bit bitmaps, but I am lost as to how to do this for 4 and 8 bit bitmaps
The HBITMAP passed into my function could be a DIB or a DDB
HBITMAP #####::GrayScale(CDC *pDC, HBITMAP hBitmap)
{
BITMAP bmp;
::GetObject(hBitmap, sizeof(BITMAP), &bmp);
if (bmp.bmBitsPixel < 16)
{
}
else
{
HBITMAP hDib = (HBITMAP)::CopyImage(hBitmap, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG | LR_CREATEDIBSECTION);
DIBSECTION DibSection;
::GetObject(hDib, sizeof(DIBSECTION), &DibSection);
int Size = DibSection.dsBmih.biWidth * DibSection.dsBmih.biHeight;
BITMAPINFO bmi;
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biHeight = bm.bmHeight;
bmi.bmiHeader.biWidth = bm.bmWidth;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = bm.bmBitsPixel;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = ((bm.bmWidth * bm.bmBitsPixel + 31) & (~31)) / 8 * bm.bmHeight;
bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
BYTE *pBits;
::GetDIBits(pDC->m_hDC, hDib, 0, bm.bmHeight, pBits, &bmi, DIB_RGB_COLORS);
...
...
::SetDIBits(pDC->m_hDC, hDib, 0, bm.bmHeight, pBits, &bmi, DIB_RGB_COLORS);
return hDib;
}
}
It is my understanding that in 4 and 8 bit bitmaps, the bits returned by GetDIBits() are actually pointers into a colour table, and to change the image to grayscale I have to change the colour table. How do I get access to the colour table
I have tried
::GetDIBColorTable(memDC.m_hDC, 0, 1<<bmp.bmBitsPixel, rgbquad); For a 256 colour bitmap, ::GetDIBColorTable() returns 256, but the rgbquad array is full of garbage (every entry is 0xcc in debug mode). I have read Zafir Anjum's Drawing an image in grayscale but I could not get that to work the way i wanted either. I have tried several other things but nothing seems to work
I am probably missing something obvious and I hope some one can point out to me what it is.
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
The GetDIBColorTable code you gave works. Are you using CopyImage with LR_CREATEDIBSECTION as you in the code for non palettized bitmaps?
Here's my test code (in C). It was successful in retrieving the palette of a 4 bit and 8 bit bitmap made with MS Paint.
HBITMAP hbm = NULL, holdbm = NULL;
HDC hdc = NULL;
RGBQUAD pal[256];
BOOL MainFrm_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct)
{
hbm = (HBITMAP)LoadImage(NULL, TEXT("test.bmp"), IMAGE_BITMAP, LR_DEFAULTSIZE, LR_DEFAULTSIZE, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
if(hbm)
{
BITMAP info;
GetObject(hbm, sizeof(BITMAP), &info);
hdc = CreateCompatibleDC(NULL);
if(hdc)
{
holdbm = SelectBitmap(hdc, hbm);
GetDIBColorTable(hdc, 0, 1<<info.bmBitsPixel, pal);
}
}
return TRUE;
}
|
|
|
|
|
I'm sure this may be a usual question here but I want my app to check my POP3 account!? HOW, is there some greit classes here somewhere??
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
|
Hi,
I used this class some time ago. It worked fine at first. But after some time I got a strange error. I realized that the program was unable to create the socket. Then using GetLastError method, I found the error:
"Either the application has not called WSAStartup, or WSAStartup failed."
Then I called WSAStartup method in the constructor and WSACleanUp in the destructor. I am not sure if this is the correct way or not. Are there other ways to do it?
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
see :-
http://www.codeproject.com/internet/cpop3conn.asp
http://www.codeproject.com/internet/popwatch.asp
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hi,
I have three problems.Please answer.
Problem 1:(BIGGEST)
-------------------
I make a call like this
OnDraw(CDC *pDC)
{
//.....
MyDrawFunction(pDC);
//....
}
Should I release the CDC * in my function because
1)When I scroll rapidly,the figures drawn by my
function looses color;
2)When I use Alt-Tab and return to my program,
the figures will be displaced.
But these things donot happen to the figures drawn by the
OnDraw function.What is the problem?
Problem 2:
---------
When I create DCs inside my function like
CDC *MyDC = GetDC(); or
CClientDC dc(this) etc
and draw with it,I find problem while scrolling.The figures get smudged.
How to avoid this?
Problem 3:
---------
The exact same thing an in Problem 2 happens when each row in a
list control uses a different color.The colors get mixed while
scrolling.
Thanx
|
|
|
|
|
Can you post your function please!
Then I perhaps can help ya!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I'm stuck with the following problem. From one application, given the handle to the parent window of another app and the controlIDs of a control (textBox, button, etc) in the app, I need to get the handle of the control in run time.
GetDlgItem() can be used to get the handles of a control in a Dialog based window, But it returns me wrong handle values when I tried with Windows explorer - a SDI based app. Could somebody please point me the approach to get the handles of the controls in a complex window full of combo box, buttons, menus and tree views?
Thanks for any help,
Wally
|
|
|
|
|
Well, you see it's impossible untill you find a SDK of it (like WinAmp) where the developers tell you you the ID of all buttons, list-boxes etc..... therefor you can reach the controls! You need the ID for alla controls and you can't get them in another app just like that!
But now when you read this messeage, try find an answer somewhere else! I can be wrong!!
But whit my research with the problem I havn't found anything that can do what I want!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Idea:
0. CreateWindow
hMenu
[in] Handle to a menu, or specifies a child-window identifier depending on the window style. For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; it can be NULL if the class menu is to be used. For a child window, hMenu specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The application determines the child-window identifier; it must be unique for all child windows with the same parent window.
Steps:
1. EnumChildWindows
2. GetWindowLong
GWL_ID Retrieves the identifier of the window.
It's all.
Good lack!
|
|
|
|
|
I've faced with some odd problem in my code. I have CTreeView in my app and want to display popup menu when I'd made right mouse click at some tree element. In my NM_RCLICK handler I cast pNMHDR to pointer to NMTREEVIEW structure as usuall I had done with CListCtrl - NMLISTVIEW. But after all of that when I tried to use values in ptDrag member I've get garbage only.
Thanks for any help
|
|
|
|
|
afx_msg void OnRclickTree1(NMHDR* pNMHDR, LRESULT* pResult);
ON_NOTIFY(NM_RCLICK, ID_XML_TREE, OnRclickTree1)
void C3DTabViewBar::OnRclickTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
UNREFERENCED_PARAMETER(pNMHDR);
// TODO: Add your control notification handler code here
TRACE(_T("OnRclickTree1\n"));
HTREEITEM hItem = m_treeClass.GetSelectedItem();
if (hItem != NULL)
{
CCMGTreeData* pData = reinterpret_cast<ccmgtreedata*>(m_treeClass.GetItemData(hItem));
switch (pData->GetType())
{
case CCMGTreeData::REFERENCES:
DoPopupMenu(IDR_REFERENCES);
break;
case CCMGTreeData::SCHEMAS:
DoPopupMenu(IDR_SCHEMAS);
break;
}
}
*pResult = 0;
}
void C3DTabViewBar::DoPopupMenu(UINT nMenuID)
{
CMenu popMenu;
popMenu.LoadMenu(nMenuID);
CPoint posMouse;
GetCursorPos(&posMouse);
UINT uiDisable = MF_BYCOMMAND|MF_GRAYED;
UINT uiEnable = MF_BYCOMMAND|MF_ENABLED;
if (nMenuID == IDR_REFERENCES)
{
popMenu.EnableMenuItem(ID_REFERENCES_ADD_MESSAGE_DEFENITION, IsRefernceIncluded(CCMGTreeData::MESSAGE_DEFENITION) ? uiDisable: uiEnable);
popMenu.EnableMenuItem(ID_REFERENCES_ADD_CLASS_OF_SERVICE, IsRefernceIncluded(CCMGTreeData::CLASS_OF_SERVICE) ? uiDisable: uiEnable);
popMenu.EnableMenuItem(ID_REFERENCES_ADD_BALANCE_DEFENITION, IsRefernceIncluded(CCMGTreeData::BALANCE_DEFENITION) ? uiDisable: uiEnable);
}
popMenu.GetSubMenu(0)->TrackPopupMenu(0, posMouse.x, posMouse.y, this);
}
Good luck!
|
|
|
|
|
Please look DAOVIEW example from MS VisualC++.
|
|
|
|
|
Thanks a lot. It really gave me a good idea.
But look at this code:
void CLeftView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
{
unsigned char *p = (unsigned char*) pNMHDR;
p -= 4; // !!!!!!!!!!!!!
NMTREEVIEW *z = (NMTREEVIEW*) p;
CPoint ptXY = z->ptDrag;
}
It works too!!! ptXY after all of these manipulations is a real mouse coordinates
|
|
|
|
|
Trust me, your code is very bad idea for support etc, etc.
Regrds,
Sergey
|
|
|
|
|
http://www.mvps.org/vcfaq/mfc/6.htm
/* Get the mouse cursor position */
DWORD dwPos = GetMessagePos();
More simple and portable.
|
|
|
|
|
I'm working on a tutorial that will explain how to define dialog templates without using resource files but it is far from done. If you cannot wait look in MSDN Library for DLGTEMPLATE and DLGITEMTEMPLATE (or their *EX equivilent).
|
|
|
|
|
OOOOOOUUUUUUU YEAH, that would be great! I got some explanations and examples, but nothing general (and MSDN-doku is a little bit *too general*).
Do you know if it's possible to make a memory-template based DialogBar?
mfg HintifLo
|
|
|
|
|
This behaviour is because you didn't use
AfxSetResourceHandle() in the DLL.
All I need is a roadmap and then I might be able to find a clue.
|
|
|
|
|
I'm currently developing an MDI web browser and I cannot seem to find the proper logic/implimentation on how I can effective use a history list for the users navigation. What I mean is, I don't know exactly how I can implement it so that when the user click on a link, the forward history list is blanked out and the button greyed out. Does anybody know how I could possibly implement this??
TIA
|
|
|
|
|
Hi everybody!!!
How can I get the path to the registry key of my application, that uses WriteProfile...() and ReadProfile...() functions?
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
Hello,
I was wondering if there was a way to set how far an icon is from the top in a list control?
For example if I only have 1 row of items. Is it possible to center it in the list control, so that it appears to be in the middle?
Thanks in advance!
|
|
|
|
|
Hi,
I would like to know how to get the word under the cursor ,the word might be in any window of the other process.
Thanks in advance.
|
|
|
|