|
Wanting to call the following function using a pointer-to-function:
void func1();
Either typedef the pointer-to-function-type:
typedef void (*pfn1_t)();
or use it as-is:
int main()
{
void (*pfn1)();
pfn1 = &func1;
(*pfn1)();
pfn1_t pfn1_ = &func1;
(*pfn1_)();
return 0;
}
|
|
|
|
|
Or, to make the code simpler, drop the * before the function pointer, since it's unnecessary:
(*pfn1)(); becomes pfn1();
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
I'm hoping most of you have seen Winamp...
I want to know how they made that Winamp app look and feel the way it does. I'm not interested in the skins that we can add on, but in the way they managed to make a really thin title bar, a tiny scroll bar, etc etc. (btw: is Winamp a fancy dialog box )
|
|
|
|
|
> I'm not interested in the skins that we can add on, but
> in the way they managed to make a really thin title bar
WM_NCPAINT and company.
|
|
|
|
|
If I were doing a WinAmp-like UI, it would be a window with no caption or border, and all the UI elements drawn manually (including buttons and scrollbars). When a WM_LBUTTONDOWN message arrived, I'd compare the mouse coordinates with the RECTs of all the "controls" to figure out which "control" was clicked on.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Given declarations like this:
void func(int, int (*)(int, int));
class a
{
public:
static int func1(int b, int c);
};
Is it possible with modification to do this:
...
ret = func(0, a::func1);
...
Or is there a better Object Orientated solution? I'm kind of baffled.
|
|
|
|
|
> Given declarations like this:
> void func(int, int (*)(int, int));
This one returns "void".
class a {
public:
static int func1(int b, int c);
};
Disregarding parameters, this one returns int. Are you really sure you want to do this? If you are, try reinterpret_cast, but I'm quite confident you'll find std::mem_fun more suitable.
|
|
|
|
|
Change
void func(int, int (*)(int, int));
to
void func(int, int (a::*)(int, int));
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
I'm reading an INI file with GetPrivateProfileString on a windows 2000 machine. When I read a string, I get back the entire line including any comment that might be there, like so:
"value ; this is the comment"
This is *not* the desired nor the expected result - I've been using INI files for a long time and have never seen this happen before.
One strange thing about this ini file is that the keys look like this:
thiskey = value ; this is the comment
There is a space between the keyname and the equal sign, and between the equal sign and the value. Could this be what's causing the retrieval of the comment as well as the value?
Next question, is there a way to programatically get/set a comment in an ini file (short of treating it like a normal text file)?
|
|
|
|
|
I'm afraid the .ini file syntax hasn't been specified too clearly by MS or whoever.
Since it is not detailed what a string to be read by Get(Private)ProfileString(),
I won't make any assumptions regarding special characters.
The only comment I have yet come across is the single line comment, that is a line
starting with a ';'
A rest-of-line comment would demand specific treatment of the ';' character.
It seems to be unimportant wether the '=' is surrounded by whitespace or not.
To get slightly more (and less) control of how an .ini file is accessed, use
Get(Private)ProfileSection(), which reads a whole section into memory.
|
|
|
|
|
1. What is the best way to reboot the system which is really not platform specific?
ExitWindowsEx seems to be the function, but it has too many
platform restriction. I tried looking for a KB but could not
find anyone on this.
Any help?
2. I have a simply installation startup, which will install some system stuff like DCOM95/MDAC/50COMUPD/HHUPD before executing the main program to be installed.
Most of the updates require a reboot, and I use the RunOnce registry key to automatically restart the installing steps.
The problem is the main installation is Windows Installer
based program and I wish to follow the tradition here to allow the user access to the desktop. However, with the RunOnce key, Windows seems to wait for the program to complete before displaying the desktop. Is there any good way to yield control to Windows to display the desktop?
Best regards,
Paul.
|
|
|
|
|
The ExitWindowsEx function will work on all Windows platforms, but under NT/W2k/XP, you will have to check and/or modify the system privileges to enable the ExitWindowsEx call to work correctly.
See this link on CodeGuru for some code:
http://codeguru.earthweb.com/cgi-bin/bbs/wt/showpost.pl?Board=vc&Number=232529&page=16&view=collapsed&sb=5
Cheers,
Peter
|
|
|
|
|
Thanks, just looking for a safer ways and I got it now.
Regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan, and open for day job or programming contract anywhere!
|
|
|
|
|
It seems that WS_EX_LEFTSCROLLBAR style is not working with combo boxes - has anybody found a solution to that?
Even thought there is a property called "left scrollbar" in the resource editor, it does not change a scroll position. ModifyStyleEx is also not working...
|
|
|
|
|
It works on my Win2000 box. Are you sure that you have enough items in your combobox to actually display the scrollbar? Combos with no items display no scrollbar at all.
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
Yes, it filled with items and I have a scroll bar but in the usual place, that is on the right. I am on NT4 thought - gottat test it at home with w2k...
Using a SPY++ I can see that the drop style has changed if I use ModifyStyleEx against the ListBox part of combo only, the resource editor only changes the style of the edit part. I tried all the combo types - simple, drop down and list to no avail... Strange...
Dziekuje za pomoc.
|
|
|
|
|
From the CreateWindowEx docs in MSDN:
"WS_EX_LEFTSCROLLBAR: If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored."
Have no idea what if W2K US-English shell supports Hebrew, Arabic or reading order alignment. Seems that you can forget about this style if your app is going to run on different Windows versions.
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
Yeah, it looks like it works on my "English-speaking" w2k as well.
How annoying is that!
Cheers
|
|
|
|
|
Hi all,
I have two application, A.EXE and B.EXE. The two applications communicate using OLE Automation method. A.EXE is the server and B.EXE is the client. Now, I want B.EXE to pass a HWND to A.EXE, and A.EXE will draw image at the given HWND. I can't make it.
CWnd::FromHandlePermanent(hWnd) return NULL.
I would like get advice from codegurus here whether this approach is possible or not. If not, is there any other method to do so?
thanks
regards,
yhtay
|
|
|
|
|
> Now, I want B.EXE to pass a HWND to A.EXE, and A.EXE will draw
> image at the given HWND.
[...]
> I would like get advice from codegurus here whether this
> approach is possible or not.
No.
|
|
|
|
|
Is the HWND just the handle to the main window for B.EXE ? If so, why not just enumerate the windows and find it that way ? Or use Copydata to send the info between processes ?
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hi All,
I am working with VC++(Windows NT).I have created an ATL Service !Now, what I want firstly is that when I run that service, it should not appear in the Task Manager .But, at the background the process should be running ! How can I do that ?Which is the suitable API function for this ?
Thanx in advance for the Help .
Yamini Devi
|
|
|
|
|
Try to look at following adress:
http://www.codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vc&Number=203057&page=0&view=collapsed&sb=5&category=
Alex
|
|
|
|
|
Hi All,
I am working with VC++.I have created an ATL Service !Now, what I want firstly is that when I run that service, it should not appear in the Task Manager .But, at the background the process should be running ! How can I do that ?Which is the suitable API function for this
|
|
|
|
|
Hi there, can someone give me an idea as to why this code:
/*****************************************************/
/* draw some text */
/*****************************************************/
CRect rect;
CFont TextFont, *oldFont;
CWnd *wnd = GetDlgItem(IDC_PLACEHOLDER); // find where to put the text (a static control)
ASSERT(wnd != NULL);
ASSERT(IsWindow(wnd->m_hWnd) != FALSE);
wnd->GetWindowRect(&rect);
ScreenToClient(&rect);
CPaintDC dc(this) ; // device context for painting
if (m_dc.GetSafeHdc() == NULL)
{
m_dc.CreateCompatibleDC(&dc) ;
m_bitmapTitle.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height()) ;
m_pbitmapOldTitle = m_dc.SelectObject(&m_bitmapTitle) ;
}
TextFont.CreateFont (40, 0, 0, 0, 300, // Create the font
TRUE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Arial") ;
oldFont = m_dc.SelectObject(&TextFont); // select the font
m_dc.SetTextColor (RGB(128, 0, 0)) ; // set a bunch of attributes of the dc
m_dc.SetBkMode(OPAQUE);
m_dc.SetBkColor(::GetSysColor(COLOR_3DFACE));
m_dc.SetTextAlign (TA_LEFT);
CString Title = "Test ";
m_dc.TextOut(0, 0, Title);
m_dc.SelectObject(oldFont) ;
CDC memDC ;
CBitmap memBitmap ;
CBitmap* oldBitmap ; // bitmap originally found in CMemDC
// create a memory dc
memDC.CreateCompatibleDC(&m_dc) ;
memBitmap.CreateCompatibleBitmap(&m_dc, rect.Width(), rect.Height()) ;
oldBitmap = (CBitmap *)memDC.SelectObject(&memBitmap) ;
if (memDC.GetSafeHdc() != NULL)
{
// draw the text on the memory dc
memDC.BitBlt(0, 0, rect.Width(), rect.Height(),
&m_dc, 0, 0, SRCPAINT) ;
// bitblt the result to the display DC
dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
&memDC, 0, 0, SRCCOPY) ;
}
memDC.SelectObject(oldBitmap) ;
/*****************************************************/
/* done... */
/*****************************************************/
produces perfectly fine output on Win NT but garbage on win 95/98/Me?? I'm stuck!!
to understand what I mean about garbage, please see Win NT and Win98
Thanks in advance for any help!
Liam O'Hagan
Thanks
Senior Test Engineer
GLI Australia
www.gli.com.au
|
|
|
|
|