|
Hi all,
I want to display a Bitmap on my static control.
For Doing so i have written this line of code
<pre>m_Bitmap.SetBitmap( ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BMP1)) );</pre>
But it is not displaying the bitmap.
What should i do..
|
|
|
|
|
Are you sure that LoadBitmap() is correctly returning a handle to the image? Also MSDN recommends you use LoadImage()[^] in preference.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
My application is developed using Visual studio 2008 and it is MFC application. It is using one XML configuration file and it is deployed with the application. As per the change of requirment, we should not deploy the XML file in to customer machine instead we have to deploy the binary of that file.
How can I convert the XML in to binary file and get the data from the binary file again?
I am thinking serializtion is one option, is there any easy way to do this?
Thanks in advance.
-Mutpan
|
|
|
|
|
It depends on what type of data you need with the application. Is there any reason why you cannot add this as a resource?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
The file is not the same for all the user of the application, it is different for each user. So i cann't add it to resource.
|
|
|
|
|
In that case why use XML at all? Just create a binary file that encodes the information you require, and add code to your application or installation program to read and process the contents.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I imagine the changed requirement is to prevent your customers from seeing the details of the configuration file?
If so, I'd suggest simply obfuscating the XML by running it through some encoder/decoder. This way, you still have the benefits of an extensible and flexible format, at the cost of an extra step when reading/writing the file.
Of course, how complicated this would be depends on what XML parser you are using, as I don't think there's one in MFC.
If your parser can parse from and export to a string - and if the string isn't excessively large - you can simply read your encoded binary data from file, decode it to a string, and parse that. Similarly, when saving the config, you'd export to a string, encode that, and save it to file. If your parser needs to work with files, you can use the %TEMP% area for the conversion.
There are plenty of encoders you could use, from base64 to libzip to various crypto algorithms, so just pick one that is quick, and simple to integrate.
|
|
|
|
|
mutpan wrote: It is using one XML configuration file and it is deployed with the application.
That doesn't really sound like a 'configuration' file to me.
What are your real requirements?
Why exactly does it need to be binary?
|
|
|
|
|
Hi.
I want to develop in an embedded system. It's OS dos not support any graphic API and functions except SetPixel for developer.
I need to use some standard font for text drawing.
If you have any idea to do that, please share with me.
Thanks very much.
|
|
|
|
|
You'll have to write your own routines for drawing text.
The way this was done back in the day was to create a fixed-size font (usually consisting of 8x8 monochrome pixels, so each character would take 8 bytes to describe), and a simple look-up algorithm (in this case something like "base address of font + character code * 8).
If you have to work pixel by pixel, I'd start with writing a routine to draw a row of 8 pixels, and use that to draw the whole character.
There are some classic old fonts to look at here: http://damieng.com/blog/2011/02/20/typography-in-8-bits-system-fonts[^]
You'd have to convert them to your own format, but that's reasonably trivial. If you take the first (PET), resize it so that there's one real pixel per used pixel, and save the image as a monochrome (2-bit) bitmap, you can read it out from there.
|
|
|
|
|
Thanks a'lot for your attention and your nice response.
|
|
|
|
|
I want to insert into a listview an item with an image :
BOOL CTestListImageView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= LVS_REPORT;
return CListView::PreCreateWindow(cs);
}
and
void CTestListImageView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl& ListCtrl = GetListCtrl();
m_TraceImageList.Create(IDB_BITMAP_TRACEIL,16,1,ILC_MASK);
ListCtrl.SetImageList(&m_TraceImageList,TVSIL_NORMAL);
ListCtrl.InsertColumn(0, _T("Machine model"),LVCFMT_LEFT, 200);
ListCtrl.InsertColumn(1, _T("Description"), LVCFMT_LEFT, 250);
int nIndex = ListCtrl.InsertItem(0, _T("Test"),2);
ListCtrl.SetItemText(0,1, _T("aaaaaaaaaa"));
}
CTestListImageView class is derived from CLIstView, the m_TraceImageList data member is type of CImageList class, and have 10 images ...
still, the listview have not any image ( icon ) ... why ?
Why ? What I have do wrong ?
One mention : I prefer to insert an item with image with follow prototype :
int InsertItem( int nItem, LPCTSTR lpszItem, int nImage );
not with
int InsertItem( const LVITEM* pItem );
Thank you.
|
|
|
|
|
Flaviu2 wrote: m_TraceImageList.Create(IDB_BITMAP_TRACEIL,16,1,ILC_MASK);
Have you tried different values for the cx and nFlags parameters?
Flaviu2 wrote: ...the m_TraceImageList data member is type of CImageList class, and have 10 images ...
Where are those images being added?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Sorry for delay :
DavidCrow wrote:
Flaviu2
wrote: m_TraceImageList.Create(IDB_BITMAP_TRACEIL,16,1,ILC_MASK);
Have you tried different
values for the cx and nFlags parameters?
I have try in follow ways :
m_TraceImageList.Create(IDB_BITMAP_TRACEIL,16,1,ILC_COLOR);
m_TraceImageList.Create(IDB_BITMAP_TRACEIL,16,1,ILC_MASK);
m_TraceImageList.Create(IDB_BITMAP_TRACEIL,16,1,ILC_COLOR | ILC_MASK);
m_TraceImageList.Create(IDB_BITMAP_TRACEIL,16,2,ILC_COLOR | ILC_MASK);
m_TraceImageList.Create(IDB_BITMAP_TRACEIL,16,1,ILC_COLOR8 | ILC_MASK);
but un vain ...
DavidCrow wrote:
Flaviu2 wrote: ...the m_TraceImageList data member is type
of CImageList class, and have 10 images ...
Where
are those images being added ?
these iages are into an bitmap resource, IDB_BITMAP_TRACEIL
named ... I use the same technique for an treeview and goes well ...
|
|
|
|
|
Have you tried using LVSIL_SMALL when setting the image list?
If you vote me down, my score will only get lower
|
|
|
|
|
Also TVSIL_NORMAL is a tree control image list style flag, you would need LVSIL_NORMAL. the values may be different.
If you vote me down, my score will only get lower
|
|
|
|
|
Now it goes with TVSIL_SMALL .. thank you all.
|
|
|
|
|
Hi
I want to show a modeless dialog (in a SDI project) that I can use it when any other modal dialog of project is open.
I set the always on top style so I can see it when any other project's modal dialog is open, but I can't use it. I must close the modal dialog first and after that I can use my first dialog(modeless).
I set the parent window to CMainFrame and then NULL, but both ways did not work fine.
Also I tested some other styles, but found nothing.
Is there any way to do this?
www.logicsims.ir
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">Hadi Dayvary wrote:</div>...but I can't use it.</blockquote>
Why? What's the problem? Does it show but can't be interacted with? Does it show but stays in the background? Does it fail to show? How, and when, are you displaying it?
<blockquote class="FQ"><div class="FQA">Hadi Dayvary wrote:</div>I must close the modal dialog first and after that I can use my first dialog(modeless).<BR></blockquote>
This sounds like normal behavior of a modal dialog.
<p align="right"><small>"One man's wage rise is another man's price increase." - Harold Wilson<br /><br />"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons<br /><br />"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous</small></p>
-- modified 8-Nov-11 10:42am.
|
|
|
|
|
it's shown but can't be interacted with.
I have created it in CMainFrame::OnCreate()
like this :
m_dlgCalling.Create(IDD_CALLING, NULL);
m_dlgCalling.ShowWindow(SW_SHOW);
or this:
m_dlgCalling.Create(IDD_CALLING, this);
m_dlgCalling.ShowWindow(SW_SHOW);
www.logicsims.ir
|
|
|
|
|
So you are creating and showing the modeless dialog during the creation of the main frame, correct? Where does the modal dialog play into this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
modal dialogs come when user selects an item from the menu.
www.logicsims.ir
|
|
|
|
|
And by definition, modal dialogs must be dismissed before you can interact with any windows behind them.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I know, but I must do this for our project,
There must be a way to do something like this.
www.logicsims.ir
|
|
|
|
|
You can always create the modeless dialog via it's own UI thread. The issue is the modal dialog is preventing pumping of your messages.
onwards and upwards...
|
|
|
|