|
No, its not the same.
OldBMP in the second example is a CBitmap, not a CBitmap pointer.
SelectObject returns a CBitmap pointer, so you don't have to cast it. That was a mistake.
"It is better to remain silent and be thought a fool than to open one's mouth and remove all doubt." - Abraham Lincoln
|
|
|
|
|
I'm doing something seriously wrong. No matter where I click on the bitmap, crColourAtPoint is ALWAYS set at 16777215. I don't understand why.
CBitmap TemplateBMP;
...
TemplateBMP.LoadBitmap(IDB_PERIODIC_TMPL);
...
POINT pt;
CDC *pDC = NULL;
CDC memDC;
COLORREF crColourAtPoint = 0;
CBitmap *hOldBMP = NULL;
//obtain the point where the click occurred on the bitmap
GetCursorPos(&pt);
m_periodicBitmap.ScreenToClient(&pt);
pDC = m_periodicBitmap.GetDC();
memDC.CreateCompatibleDC(pDC);
hOldBMP = memDC.SelectObject(&TemplateBMP);
crColourAtPoint = GetPixel(memDC.m_hDC, pt.x, pt.y);
CString colourString;
colourString.Format("Colour clicked: %d", crColourAtPoint);
AfxMessageBox(colourString);
|
|
|
|
|
Make sure your pt.x and pt.y are accurate.
"It is better to remain silent and be thought a fool than to open one's mouth and remove all doubt." - Abraham Lincoln
|
|
|
|
|
They appear to be. I mean, the values will remain the same if i click in the same spot, and they'll change (in what seems to be correct) if i click in a different spot.
Out of all the elements, only 3 of them end up getting a 'matching colour' when they're clicked on. The code that I've cut and pasted into these messages all looks right though doesn't it?
Maybe I'll just re-do the template bitmap or something... I don't really know what else to do.
|
|
|
|
|
I've just submitted an article about this. You can check out the demo files/source code at:
http://www.bj-consulting.com/tln/pte_demo.zip[^]
I didn't go the bitmap route though. It is a really nifty way of determining which element was clicked on, but if you later decided you wanted to include the dicovery date of the element (or any other text) then you would have to edit your bitmap by adding text in 117 different places and when you scaled your window the text would start to look all pixellated and illegible.
The code to draw the entire table is only 14 lines and it is scalable as you change the window size. It also highlights all of the elements in the chemical group you have selected with a red border. Right clicking an element adds it to the listbox, double clicking opens a dialog box with the chemical details. Thew controls are also resizable.
Oh - it includes an MS-Access database with the elemnt info - you'll need to create an ODBC mapping to the DB - just name the datasource PeriodicTableApp
|
|
|
|
|
Thanks.
I did decide on the bitmap 'route' though. Mainly because the bitmap will only have to display the element symbol (ie. H, C, etc..) and atomic number, and I only ever require to use the element symbol. I know that even in future versions of my interface, there will be no further information required...
Although I'm still having problems getting the colours to match up. It only works right for 3/92 elements (93-110 were removed because they won't ever be used for this)...
|
|
|
|
|
Hi,
How do I make a Dialog Box Pop up as soon as it recives a event from a different process.
Thanks and Regards,
Deepak Samuel
|
|
|
|
|
SendMessage with ShowWindow
Check MSDN
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
In the event handler.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hi,
how create a dll which will connect or disconnect a modem ADLS, while using : 'user identifier' and 'password' and another thing (IP..). Connection access distant network is alredy installed. use C++ is the best way to reach connection.
but I do not manage to find the functions or objects COM which I must use.
In fact, I do not know by where to start
If somebody has an idea and can help me, thank you very much
Michel
|
|
|
|
|
Hi all,
Got a couple of easy question for the experts.
My first question is how do i remove the "x" box to close a modal dialog?
My second question is i want to know when using CFileDialog, is there a way to have the default file name to be incremented or have a number added to the end of it if it already exists?
If someone could show me how to do this, i would really appreciate it.
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
You can uncheck the System Menu option to remove the Maximize, Minimize, and close buttons. But if you want to have Max/Min buttons, then what you can probably do is to grey out the close button. For that you, just add this to the end of your InitDialog( )
VERIFY( pSysMenu->DeleteMenu( SC_CLOSE, MF_BYCOMMAND ) );
CFileDialog doesn't have any options like that. You will have implement it in your own way.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Hi,
A very simple problem yet I didn't find the solution. How can I make some buttons of the toolbar to remain pressed after the first click and came back up at the second click? Like the B (bold), I (italic) and U (underline) in Outlook, Word, etc.
Thanks
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Implement the UPDATE_COMMAND_UI handler for the button, and then use pCmdUI->SetCheck ( 1 ) for keeping the button pressed, and with parameter 0 for releasing it.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
how do i detect when user kills the application using end process tab in task manager.I tried using wm_queryendsession and terminateprocess but neither seems to be work?
|
|
|
|
|
Hi,
Just try out this.
TerminateProcess is called when one try to kill process using task manager. By default, it is not possible to kill a process that is running under a security context different than the one of the process who issued the call to TerminateProcess.
So mark ur application as service or system process. Then u may get notification if sombody tries to kill ur appln through Task Manager.
The chosen One
|
|
|
|
|
Hi,
I have a slight problem with a tree control. I cannot manage to insert items again after having deleting the whole thing.
I tried this :
<br />
HTREEITEM hMyItem = m_TreeCtrl.InsertItem( "my item" );<br />
HTREEITEM hMyChildItem = m_TreeCtrl.InsertItem( "my child item", hMyItem );<br />
<br />
m_TreeCtrl.DeleteAllItems();<br />
<br />
m_TreeCtrl.DeleteItem( TVI_ROOT );<br />
<br />
hMyItem = m_TreeCtrl.InsertItem( "my item" );<br />
hMyChildItem = m_TreeCtrl.InsertItem( "my child item", hMyItem );<br />
Instead of having "my item" as the new root in my tree, I have a blank space and no child displayed. Also, the insert functions succeed as they return a value for the items. Any ideas ?
Thanks,
Vincent
|
|
|
|
|
not tested but do not believe it is system problem
(1 and 2 are the same)
don't you have any own TVN_DELETEITEM handler or WM_PAINT?
is it called in one fn like displayed?
(what when you will not insert children? when you will not delete?)
t!
|
|
|
|
|
No to everything : no special handler, no subclasssing, nothing fancy, not called in any special function, just from a button's OnClick function.
When I don't delete, my new items are appended to the previous ones, ie
<br />
|-myItem<br />
|- myChildItem<br />
<br />
becomes<br />
|-myItem<br />
| |- myChildItem<br />
|<br />
|-myItem<br />
|- myChildItem<br />
<br />
as expected if you delete nothing and append to TVI_ROOT.<br />
|
|
|
|
|
can't be problem any unpair disable/enable-draw?
t!
|
|
|
|
|
<br />
void CMyDialog::OnBnClickedButton1()<br />
{<br />
m_ctrlTree.InsertItem( "toto" );<br />
m_ctrlTree.DeleteAllItems();<br />
m_ctrlTree.InsertItem( "tata" );<br />
}<br />
Here is the code, cannot be simpler ... Maybe you could try it quickly, insert a tree, associate with a variable, insert a button, copy paste my code in the event handler and see what the tree looks like.
BTW, thanks for your time
|
|
|
|
|
sorry, can't reproduce, do you have another computer or system installed?
t!
|
|
|
|
|
Hi,
I have tested code as below and it works fine
HTREEITEM hMyItem = m_myTree.InsertItem( "my item" );
HTREEITEM hMyChildItem = m_myTree.InsertItem( "my child item", hMyItem );
// 1. I delete the items I just inserted
//--
m_myTree.DeleteAllItems();
// OR 2. (according to the MSDN that should do the same)
//--
m_myTree.DeleteItem( TVI_ROOT );
hMyItem = m_myTree.InsertItem( "my item" );
hMyChildItem = m_myTree.InsertItem( "my child item", hMyItem );
Have u checked required properties of CTreeCtrl.
I don't see any problem in your code.
The chosen One
|
|
|
|
|
Just made a test ...
works with Visual Studio 6 on another machine. Does not work on my machine with Visual Studio 2003 ! Same procedure, new MFC app with the wizards, insert a new tab control in the dialog, add a simple button, implement the event handler of the button to do: InsertItem; DeleteAllItems; InsertItem;
Glups. Does anybody have the same problem or does this just come from the piece of s**t behind my keyboard ?
|
|
|
|
|
How to stop other Process use ReadProcessMemory to Inject into my Process?don't use APIHOOK?
|
|
|
|