|
Not sure if this tool is what you're looking for, but it's really cool nonetheless:
Hex Workshop
Ty
|
|
|
|
|
I'm sure it was asked a hundred times, but I just dont find it.
So, how do I get the screen position (or any position) of MY icon in the system tray? I need it to display a balloon tip pointing toward it.
int x=1, y=5;
x^=y^=x^=y;
<a href="http://www.codeproject.com/tips/StupidXORTrick.asp" target="_blank">ClickHereForHelp();</a>
|
|
|
|
|
I'm sure you already new this, but in 2k/XP the OS does provide balloon tooltips natively.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Use Shell_NotifyIcon function in ANY win32 OS to set tooltip text. Everything else will be done by windows.
Warm regards,
Vladimir V. Polischuk
AlarIT developer
E-mail: greykite@mail.ru
URL: http://www.alarit.com
|
|
|
|
|
That is really helpful. [imagine sarkastic grin here]
int x=1, y=5;
x^=y^=x^=y;
<a href="http://www.codeproject.com/tips/StupidXORTrick.asp" target="_blank">ClickHereForHelp();</a>
|
|
|
|
|
yes, i know it and they are f... bad like the normal tooltips. Nope. I want some nice ones. So? How i get the position?
int x=1, y=5;
x^=y^=x^=y;
<a href="http://www.codeproject.com/tips/StupidXORTrick.asp" target="_blank">ClickHereForHelp();</a>
|
|
|
|
|
I've created an mfc-dll which contains a shared memory zone, to be shared by 2 instances.
The first instance creates the memory zone using CreateFileMapping() . The second instance opens the memory zone using OpenFileMapping() . They both get the pointer to the address of the first byte of the memory using MapViewOfFile() .
That works just fine on a win98 machine. The 2 instances get the same address.
But if we run it on a winNT, the MapViewOfFile returns different addresses for the 2 instances (shared memory huh?). How is that possible?
Here's how I created the memory:
if(bInit)
{
hMapHandle=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,SHMEMSIZE,"XE_MEMORY_MAP");
if(!hMapHandle)
AfxMessageBox("CreateFileMapping failed");
}
else
{
hMapHandle=OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,"XE_MEMORY_MAP");
if(!hMapHandle)
AfxMessageBox("OpenFileMapping failed");
}
lpMapAddress=MapViewOfFile(hMapHandle,FILE_MAP_ALL_ACCESS,0,0,0);
if(!lpMapAddress)
AfxMessageBox("MapViewOfFile failed");
if(bInit)
memset(lpMapAddress,0,SHMEMSIZE);
char buf[100];
sprintf(buf,"memory initialised: %d",bInit);
AfxMessageBox(buf);
sprintf(buf,"\tlpMapAddress=%p",lpMapAddress);
AfxMessageBox(buf);
lpMapAddress points to the same address on win98, but not on NT.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Curious, but why did you think they should? Nothing ever states that you'd get the same results. Consider it more a coincidence than anything else. Never rely on the fact that it gives the same address in two processes.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
That's the whole point of shared memory. 2 applications that use the same memory.
So, by definition, the addresses MUST correspond. Otherwise it's no longer shared memory.
ex.
Using the first instance, we put an integer on address 666. Now, if we want to read that integer with the second instance, we need to know the address. In my case here, on win98 the address for the second instance is 666, but on winNT it is 1024 and so it doesn't refer to the same integer.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Grote Smurf (aka frisco) wrote:
So, by definition, the addresses MUST correspond. Otherwise it's no longer shared memory
Not at all. One process may get base address equal to 1000, another to 2000. If process 2 sets the address 2010 to 55, then first one will see 55 at 1010. Virtual memory, you know
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Ok, understood. So, linked lists are not an option here (what was I thinking, pressure).
But we can have an array of objects starting at a base-address. That's right, isn't it? So all I have to do is count from the address lpMapAddress to access all the objects.
Bassicly, I've been programming in java for several years, neglecting c for quite a while. I forgot that you can't assume anything in c++ . It's just a coincidence that the win98 returns the same address.
carry on...
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Grote Smurf (aka frisco) wrote:
linked lists are not an option here (what was I thinking, pressure).
Don't think so. Instead of pointers, use offsets. To create a real pointer, add offset to base address.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
You're right, but it seems easier to have something like pMyPointer++.
It doesn't have to be speedy, you know.
Nevertheless, this is just for a testcase. Next week, I'll start implementing this in our app, then I'm going to do the linked list for sure.
tnx again!
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Grote Smurf (aka frisco) wrote:
You're right, but it seems easier to have something like pMyPointer++.
There's nothing which could stop you from implementing smart pointer class. Providing operator++ would be trivial.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
Smart pointers. I've already used them in a direct-x app, but never actualy created one.
Maybe I'll use it for the real thing next week. Now, an array's just fine
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Wrong! They use the same memory, yes. But they DO NOT have to map to the same memory address in your process. They share the same memory in the page file, but each process can obtain a different pointer. You are guaranteed that changing the memory in one changes it for the other, but beyond that nothing. This is by design, it's working as it should.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Grote Smurf (aka frisco) wrote:
lpMapAddress points to the same address on win98, but not on NT.
So what? It's not possible to guarentee that addresses in multiple memory spaces will be identical. You should store lpMapAddress outside the shared data section.
Tomasz Sowinski -- http://www.shooltz.com
** Putt knot yore thrust inn spel chequers. **
|
|
|
|
|
I think you need to prepend global to your name
"Global\\XE_MEMORY_MAP"
if I remeber correctly.
Todd Smith
|
|
|
|
|
Hello,
I'm getting compile errors
error C2146: syntax error : missing ';' before identifier 'm_pConnection'
error C2501: '_ConnectionPtr' : missing storage-class or type specifiers
error C2501: 'm_pConnection' : missing storage-class or type specifiers
I used the Add Memeber Variable menu to create the variable. I'm not quite sure what is causing this. Any help
would be much appreciated.
Thanks
Karl
|
|
|
|
|
It doesn't know the type of variable m_pConnection is,
include the header file for the type.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Hello,
Thanks for the reply and I did check my source fill and I
found what I do believe is all the required header files
They are
#include "stdafx.h"
#include "PopulateDataGrid.h"
#include "PopulateDataGridDlg.h"
<br />
<br />
#if !defined(AFX_POPULATEDATAGRIDDLG_H__F98751E6_C09A_11D6_93C2_DF66D2E79326__INCLUDED_)<br />
#define AFX_POPULATEDATAGRIDDLG_H__F98751E6_C09A_11D6_93C2_DF66D2E79326__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
<br />
class CPopulateDataGridDlg : public CDialog<br />
{<br />
public:<br />
_ConnectionPtr m_pConnection;<br />
CPopulateDataGridDlg(CWnd* pParent = NULL);
<br />
enum { IDD = IDD_POPULATEDATAGRID_DIALOG };<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
<br />
protected:<br />
HICON m_hIcon;<br />
<br />
virtual BOOL OnInitDialog();<br />
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);<br />
afx_msg void OnPaint();<br />
afx_msg HCURSOR OnQueryDragIcon();<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
Thanks
Karl
|
|
|
|
|
So where is _ConnectionPtr defined?
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Hello,
If you look at my previous post you will see that it was
defined at "PopulateDataGridDlg.h" file.
Thanks
Karl
|
|
|
|
|
I'm assuming you are using
#import "C:\Program Files\Common Files\System\ADO\msado15.dll"
or some other similiar #import.
You need to make sure this line is before the call to #include "PopulateDataGridDlg.h"
Either that or your #import is specifing a namespace which you will need to prefix your _ConnectionPtr with.
Michael
Programming is great. First they pay you to introduce bugs into software. Then they pay you to remove them again.
|
|
|
|
|
Hello Micheal,
Thanks for your reply and yes I did have the specified #import included. presently it is placed in "StdAfx.h" file
<br />
<br />
#if !defined(AFX_STDAFX_H__F98751E8_C09A_11D6_93C2_DF66D2E79326__INCLUDED_)<br />
#define AFX_STDAFX_H__F98751E8_C09A_11D6_93C2_DF66D2E79326__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers<br />
<br />
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>
#include <afxdtctl.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT<br />
#include <afxcmn.h>
#endif // _AFX_NO_AFXCMN_SUPPORT<br />
<br />
#undef EOF<br />
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename_namespace("ADO20") <br />
<br />
#endif // !defined(AFX_STDAFX_H__F98751E8_C09A_11D6_93C2_DF66D2E79326__INCLUDED_)<br />
|
|
|
|