|
|
I am trying to make Full screen (800 x 480) apps for vehicle PC's.
like this one:
http://i615.photobucket.com/albums/tt235/I_want_to_learn/SentaFS.jpg [i615.photobucket.com]
I'm trying to do apps like that with Fully Alpha Blended PNG's.
I managed to load a PNG as the Dialogs Background and one as a Button.
The button has 2 images:
1: The Normal State
2: the Down (Pressed) State
The problem i'm having is that every time i click the button, the "Down State" PNG gets drawn on top of the "Normal State" PNG and you can clearly see the Normal state Icon in the back of the button's Downstate Image and Viceversa
How can i clear or erase the the normal state image if i click my button and viceversa when i release my button.
If i put a solid background to the button i can fix the image overlapping problem but i get a big color full square, i need to redraw the button with the new image but still having the transparent background.
This is the code for my DialogBox:
#include "stdafx.h"
#include "ODBII Maker Database.h"
#include "ODBII Maker DatabaseDlg.h"
#include "SearchButton.h"
#include <fstream>
#include <gdiplus.h>
#include <gdiplusenums.h>
#pragma comment (lib,"gdiplus.lib")
using namespace std;
fstream database;
CString ItemText;
int mark;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CODBIIMakerDatabaseDlg::CODBIIMakerDatabaseDlg(CWnd* pParent )
: CDialog(CODBIIMakerDatabaseDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CODBIIMakerDatabaseDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_Maker);
DDX_Control(pDX, IDC_FIND, Search);
DDX_Control(pDX, IDC_CODE, m_Meaning);
DDX_Control(pDX, IDC_Meaning, m_Code);
}
BEGIN_MESSAGE_MAP(CODBIIMakerDatabaseDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_FIND, &CODBIIMakerDatabaseDlg::OnBnClickedFind)
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
BOOL CODBIIMakerDatabaseDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
Gdiplus::GdiplusStartupInput gdiplusstartupinput;
Gdiplus::GdiplusStartup(&gdiplusToken,&gdiplusstartupinput,NULL);
char Maker[MAX_PATH];
m_Maker.InsertColumn(0,"");
m_Maker.SetColumnWidth(0,180);
database.open("Manufacturers//Manufacturer.txt",fstream::in);
while (database.getline(Maker,sizeof(Maker)) != 0)
{
m_Maker.InsertItem(0,Maker);
}
database.clear();
database.close();
return TRUE;
}
void CODBIIMakerDatabaseDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CODBIIMakerDatabaseDlg::OnPaint()
{
CPaintDC dc(this);
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<wparam>(dc.GetSafeHdc()), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CODBIIMakerDatabaseDlg::OnQueryDragIcon()
{
return static_cast<hcursor>(m_hIcon);
}
void CODBIIMakerDatabaseDlg::OnBnClickedFind()
{
CString Search;
CString Folder;
char Temp[MAX_PATH];
char Code[MAX_PATH];
char Meaning[MAX_PATH];
m_Meaning.SetWindowTextA("");
Search = "[";
m_Code.GetWindowTextA(Temp,sizeof(Temp));
Search += Temp;
Search += "]";
if(m_Maker.GetSelectedCount() > 0)
{
mark = m_Maker.GetSelectionMark();
ItemText = m_Maker.GetItemText(mark,NULL);
Folder = "Manufacturers\\";
Folder += ItemText;
Folder += ".txt";
database.open(Folder,fstream::in);
while (database.getline(Code,sizeof(Code)) != 0)
{
if(strcmp(Code,Search) == 0)
{
database.getline(Meaning,MAX_PATH);
m_Meaning.SetWindowTextA(Meaning);
}
}
}
database.close();
database.clear();
}
BOOL CODBIIMakerDatabaseDlg::OnEraseBkgnd(CDC* pDC)
{
Gdiplus::Image * BG;
Gdiplus::Graphics grpx(*pDC);
Gdiplus::Rect rect(0,0,473,261);
BG = Gdiplus::Image::FromFile(L"Image\\BackGround.png",FALSE);
grpx.DrawImage(BG,rect);
return true;
}
</hcursor></wparam></gdiplusenums.h></gdiplus.h></fstream>
and this is the code for my Button:
#include "stdafx.h"
#include "ODBII Maker Database.h"
#include "ODBII Maker DatabaseDlg.h"
#include "SearchButton.h"
#include <gdiplus.h>
#pragma comment (lib,"gdiplus.lib")
IMPLEMENT_DYNAMIC(SearchButton, CButton)
SearchButton::SearchButton()
{
Gdiplus::GdiplusStartupInput gdiplusstartupinput;
Gdiplus::GdiplusStartup(&gdiplusToken,&gdiplusstartupinput,NULL);
ButtonUp = Gdiplus::Image::FromFile(L"Image\\Button1.png",FALSE);
ButtonDown = Gdiplus::Image::FromFile(L"Image\\Button2.png",FALSE);
}
SearchButton::~SearchButton()
{
Gdiplus::GdiplusShutdown(gdiplusToken);
}
BEGIN_MESSAGE_MAP(SearchButton, CButton)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
void SearchButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
CRect rt;
rt = lpDrawItemStruct->rcItem;
Gdiplus::Graphics grpx(dc);
UINT State = lpDrawItemStruct->itemState;
Gdiplus::Rect rect(0,0,90,90);
if((State & ODS_SELECTED))
{
grpx.DrawImage(ButtonUp,rect);
}
else
{
grpx.DrawImage(ButtonDown,rect);
}
dc.Detach();
}
void SearchButton::OnLButtonDown(UINT nFlags, CPoint point)
{
Invalidate(1);
CButton::OnLButtonDown(nFlags, point);
}
void SearchButton::OnLButtonUp(UINT nFlags, CPoint point)
{
Invalidate(1);
CButton::OnLButtonUp(nFlags, point);
}
BOOL SearchButton::OnEraseBkgnd(CDC* pDC)
{
Gdiplus::Graphics grpx(*pDC);
Gdiplus::Color trans(255,255,255,255);
grpx.Clear(trans);
return CButton::OnEraseBkgnd(pDC);
}
HBRUSH SearchButton::CtlColor(CDC* pDC, UINT )
{
return (HBRUSH)::GetStockObject(NULL_BRUSH);
}
</gdiplus.h>
Thanks so much in advance ^_^.
God Bless.
|
|
|
|
|
AntiBNI wrote: BOOL SearchButton::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
Gdiplus::Graphics grpx(*pDC);
Gdiplus::Color trans(255,255,255,255);
grpx.Clear(trans);
return CButton::OnEraseBkgnd(pDC);
}
Strikes me that clearing with 'transparent' won't erase the existing image(s)? You need to paint with something opaque to actually do any erasing?
|
|
|
|
|
Yep,If i erase with a transparent brush, the images will stay overlapped but if i clear with a color brush, it will work.
|
|
|
|
|
In the Ribbon Control What CMFCRibbon(Combo Box here) do i Put? ComboBox does not work or combobox. I know A button is CMFCRibbonButton and a CheckBox is CMFCRibbonCheckBox. Please Help
|
|
|
|
|
What's wrong with CMFCRibbonComboBox[^]? seems to me that its stated intent (The CMFCRibbonComboBox class implements a combo box control that you can add to a ribbon bar, a ribbon panel, or a ribbon popup menu) is just what you want?
|
|
|
|
|
Hello,
I have managed to pull a program from one of the articles
that displays an image(jpg)
I have added the following code to get each pixel on the screen
COLORREF color = pDC->GetPixel(x,y);
colorNo = (int)GetRValue(color); //Then write values to file for rgb
I then create another program to gather what has been writen
to file and then display it.
Unfortunatly what is displayed is a 'carpet like image'
I understand that the return value for GetRValue is a byte
so I have casted this.
Can any body know why I am having problems.
Is there any good programs for this?
I am doing this for game purposes, eventualy I would like to get into 3d graphics
what programs do the pro's do to save theirs
Please can anybody enlighten me.
cheers Simon
modified on Saturday, February 7, 2009 11:57 AM
|
|
|
|
|
I want to capture Text Under Mouse pointer. I have used
IAccessible::get_accName and
IAccessible::get_accValue to find out Text Under Mouse using
AccessibleObjectFromPoint .
But I want just a word that is under mouse pointer. I am looking for any help.
Thank you
Regards,
Swapnil Shah
|
|
|
|
|
|
I have already used IAccessible. This technique gives you a whole sentence. I am looking for word capture. I want to grab a word under mouse from any application. plz give me some suggestions.
Regards,
Swapnil Shah
|
|
|
|
|
Hi Swapnil,
I am not able to instantly think of a technique to get this done. Probably you can use an OCR and get the word under the mouse cursor, and then search for it in the sentence that IAccessible returned. If it's present in the sentence, you could be double sure.
Ya, I know it's dumb. But why not check if it goes through well?
I'll think on this line and write you another reply if I get a better idea.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi
Thanks for reply.
I think i should try OCR. I have never used it but i have read that its highly unreliable. plz reply me if u get any better idea.
Regards,
Swapnil Shah
|
|
|
|
|
Hi,
Did you try using an OCR? I thought over your problem statement and I realise that it's even more complex than it sounds to be.
Using the previous method I suggested, you could retrieve the entire text under the window. But, if you need the text (a word?) that's just under the mouse cursor, it would be easier if the text is selected. You could then use something like GetActiveWindow() followed a GetFocus().
If the text weren't selected, I can't think of a readily available technique to achieve this. You will have to do some research on it. If you do achieve it, that would make a nice article for CP.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
We have used the same code as given in
http://blogs.msdn.com/oldnewthing/archive/2004/04/23/118893.aspx
to capture objects under mouse in timer.But we are facing memory leakage problem.
While debuging this code we got the point of leakage is in function
AccessibleObjectFromPoint.
We already using IAccesible::Release function and VariantClear to release memory
but still memory leakage is there.
Any one know ,how to release memory used when AccessibleObjectFromPoint is called.
Please help.
Thanx in advance.
-Jay
|
|
|
|
|
Hi,
Use a forum appropriate to the topic to create a new thread. I have honestly not worked on this and so I won't be able to answer you. By creating a new thread, your question will be viewed by many people and some of them may be able to give you valuable inputs.
I think you could safely use the COM forum for this query.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I want to create a multilingual application in vc++.net using visual studio 2005. Please help me out. Please Post examples...
Thank You.
|
|
|
|
|
If you want in vc++.NET so your choice is wrong because here is for VC++.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
plz show me the VC++ example. May be...., I can get some help..
|
|
|
|
|
|
Hi all,
i m using Access database and CRecordset derive class, when i fill long string entries in database than this error comes "String data, right truncated"
please tell me how can i remove this error.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Show your code,please?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Sounds like the strings you're putting in are longer than the database schema allows - have you checked that?
|
|
|
|
|
The database field is probably set to allow a maximum number that you're exceeding? If I remember, access allows 50 characters or something like that by default for a string. Try increasing it.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I cannot execute the following code properly.
I just need to see the system function to work.
It always return a -1 (error) when I printf the function.
What could be the problem. I dont know how to use the system function.
Anybody plz try this code & type the correct code for me.
#include <stdlib.h>
#include <stdio.h>
#include<dos.h>
#include<conio.h>
void main()
{ clrscr();
printf("About to spawn command interpreter and run a DOS command\n");
printf("%d",system("dir")); //NOT WORKING...printing a -1(ERROR)
system("dir"); //NOT WORKING---I can't see anything in screen.
getch();
}
|
|
|
|
|
It worked for me. What is system(NULL) returning? Reference[^] says "The behavior and return value are platform-dependent."
|
|
|
|
|