|
Nice!!! Thanks!
I tried our solution. I was able to disable the "X," but could not recover it. Through looking up some other functions via help, I found another solution.
-----
// Disable the "X"
GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE,MF_DISABLED);
// Enable the "X"
GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE,MF_ENABLED);
-----
Furthermore, SC_CLOSE is just one of a series of menu items that can be used.
GetSystemMenu() is very powerful. Thanks!
Kuphryn
|
|
|
|
|
I've been using the ::GetDIBits function to convert from HBitmap to DIB in a thumbnailer I'm writing. The idea is to use GetDIBits to convert from any bitmap format to a 32 bpp DIB. I then render the DIB to the screen with ::StrechDiBits.
The code below works fine with W98/WMe but under W2k/XP it sometimes - very often - render transparent bitmaps. I wonder if this a bug from me or a bug from the driver of my video card (ATI Radeon DDR 64), but I got the same problem on another XP machine.
Can anybody tell me if there's something wrong in the code below ? Personnaly I give up, I tried so many things I've no more idea.
1/ We get a HBitmap from Disk
2/ Prepare for our final DIB header (pBMI)
3/ Get bitmaps bits (GetDiBits)
4/ Save the bits in a buffer from our Image class (m_pBits)
void __fastcall CP3dOBmp::CreateFromHBitmap(HBITMAP hBitmap, int Width, int Height)
{
HANDLE hDib;
BITMAPINFO* pBMI;
HDC hDC = ::GetDC(NULL);
// Get bitmap format
//::GetDIBits(hDC, hBitmap, 0, 0, NULL, pBMI, DIB_RGB_COLORS);
Create(Width, Height, 32);
int nMem = sizeof(BITMAPINFOHEADER) +
(((((Width * 32) + 31) & ~31) >> 3) * Height);
hDib = GlobalAlloc(GHND, nMem);
if (!hDib) return;
pBMI = (BITMAPINFO *)GlobalLock(hDib);
BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER *)pBMI;
pBIH->biSize = sizeof(BITMAPINFOHEADER);
pBIH->biWidth = Width;
pBIH->biHeight = Height;
pBIH->biPlanes = 1;
pBIH->biBitCount = 32;
pBIH->biCompression = BI_RGB;
pBIH->biSizeImage = ((((Width * 32) + 31) & ~31) >> 3) * Height;
pBIH->biXPelsPerMeter = 0;
pBIH->biYPelsPerMeter = 0;
pBIH->biClrUsed = 0;
pBIH->biClrImportant = 0;
// Get hBitmap data
if (::GetDIBits(hDC, hBitmap, 0, Height,
(LPBYTE)pBMI->bmiColors, // Pointer to the bits
pBMI,
DIB_RGB_COLORS)) {
memcpy(m_pBits, (LPBYTE)pBMI->bmiColors, (32/8)*Width*Height);
}
GlobalUnlock(hDib);
GlobalFree(hDib);
::ReleaseDC(NULL, hDC);
}
The GetDiBits function obviously returns a blank buffer as I don't initialize the m_pBits one and I get a transaprent bitmap.
Good luck )
Yarp
|
|
|
|
|
Try using a BITMAPV4HEADER instead of a BITMAPINFOHEADER. I had the reverse problem. I had code working under XP, but failed under 95/98. If nothing else it's worth a shot.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
I can try this, I tried nearly hundrer solutions this weekend.
I think the problem comes from a memory management difference between XP and W98. I should probably lock something somewhere.
I'll tell you here, if I got the fix.
Yarp
|
|
|
|
|
I found - at last - that the reason why it doesn't work is that the bitmap (HBITMAP) must not be selected in a device context before to proceed. Otherwise the code is good.
I tried with a BITMAPV4HEADER but I couldn't find the way to call GetDiBits properly and gave up, so I don't know if it would have solve the problem but I guess not.
Tonight I am happy
Cheers,
Yarp
|
|
|
|
|
The idea is to use GetDIBits to convert from any bitmap format to a 32 bpp DIB.
That seems like a very slow way of creating a 32-bpp DIB compared to using CreateDibSection() and just blitting the source to the created bitmap. Just call GetObject to get the bits later on.
|
|
|
|
|
This seem a better solution, thank for the GetObject suggestion I had no idea of another way to proceed.
Unfortunately Microsoft Q195830 states that "Blitting Between DCs for Different Devices Is Unsupported (Q195830)" under XP, so I'm affraid this method is not safe enough.
Read more at http://support.microsoft.com/default.aspx?scid=kb;EN-US;q195830
I think my problem comes from memory management.
Thank for the reply, I spent my whole weekend trying to fix the bug ;(
Yarp
|
|
|
|
|
I'm using some property pages in a program, the property sheet for some reason has a "help" button on it, I tried to remove it by:
sheet.m_psh.dwFlags &= ~PSP_HASHELP;
But it still won't go, how can I get rid of it? Thanks.
BTW, I think by default the help button should not be there, right?
|
|
|
|
|
|
Cool it worked. Thank you.
|
|
|
|
|
I am trying to get a string of a MFC status-bar (original class name msctls_statusbar32) from another application (which means I access it using hwnd manipulations).. MFC obviously subclassed something there because when I do:
char Text2[1024];
int X = SendMessage(StatusBar, SB_GETTEXT, 0, (LPARAM)Text2);
*StatusBar - The MFC status-bar hwnd.*
I get in X the length as I should (25 in my case), but Text2's value is left unchanged =(.
Do you know how can I get another's application MFCs status-bar text??
Vitaly Belman
|
|
|
|
|
Does anyone know how I could use the script control to read/write to a serial comm port. A friend of mine showed me an application that does this. Inside of the script file it has commands like:
sc.read(&H1)
sc.write("42 04 3F")
Of course, I do not have the source code for this since it is not mine. But, it works slick. The readme file for the app says something that downloading the script control may be necessary for your operating system if you are getting errors so I know it uses it.
|
|
|
|
|
I don't know in what forum to ask this, but since my programs are written in VC++, I will try it here.
I've got two straigt forward questions on how to use Terminal Service and what can be done.
1. Can I write an applikation that the user launches on the server that starts a new terminal server client on the users client?
2. Can I switch logged on user while i'm inside a terminal server session?
If you know any really good site for learning TS programming, please let me know!
Not completely new to MsTsc but almost
|
|
|
|
|
Hello,
I've created a toolbar with 3 toolbar images for normal, hot and
disabled states. I load the image and create the toolbar under the Rebar
without using the resource editor. I noticed that when an adjacent band
covers part of a toolbar button the chevron's drop-down menu show up but not
include the toolbar image. Also, the drop down menu is missing in the menu
for buttons that have BTNS_WHOLEDROPDOWN or BTNS_DROPDOWN style. How do I
fix those? Thanks!
Hiu Sing Ngai
|
|
|
|
|
I use _beginthread( runSearch, 0, NULL) ; to start a search process (thread) in an application )(.cpp file).
runSearch is a void private member of a class I defined myself
However for an unknown reason I get the next Compiler error message.
C:\Program Files\Microsoft Visual Studio\MyProjects\DamageEngine0_0\CEngine.cpp(535) : error C2664: '_beginthread' : cannot convert parameter 1 from 'void' to 'void (__cdecl *)(void *)'
What do I do wrong??
I hate this type of syntax error, which cost me a lot of time.
Presumably the answer is simple (as always).
Thanks in advance,
Bert
|
|
|
|
|
A member function cannot be used as a callback unless it's static. See the VC Forum FAQ for an answer.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Try to define your thread function as:
static unsigned WINAPI runSearch(void* pThreadParameter);
That's what I use with _beginthreadex(). Hope it helps!
|
|
|
|
|
Hello,
I'm working on shell extension but I've got a problem. I would like user able to select one or more files and also folders and right click to access my software (Firegraphic XP). However, when user select more then one folder and access the "Explorer, Open or Search...", my software launch instead of the Explorer. And my software looks launch for each folder. If user only select one folder, everything seems fine. Here's the code I wrote, hope someone can give me some idea.
HRESULT CFiregrxpShEx::QueryContextMenu(
HMENU hmenu,
UINT uMenuIndex,
UINT uidFirstCmd,
UINT uidLastCmd,
UINT uFlags)
{
if (uFlags & CMF_DEFAULTONLY)
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);
if (m_files.IsEmpty())
return E_INVALIDARG;
int nMenu = 0;
// m_files is the files & folders list (can be max), if the first selected
// is a folder then I want to launch Firegraphic XP and open that folder
if (PathIsDirectory(m_files[0]))
{
InsertMenu(hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd++, _T("Browse with Firegraphic XP"));
SetMenuItemBitmaps(hmenu, uMenuIndex, MF_BYPOSITION, g_hBmpFiregrxp, NULL);
nMenu++;
}
else
{
// User selected images
}
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, nMenu);
}
HRESULT CFiregrxpShEx::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
{
if (m_files.IsEmpty())
return E_INVALIDARG;
// Get the Firegraphic.exe InstallPath
TCHAR szPath[MAX_PATH];
HKEY hKey;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Firegraphic\\Firegraphic XP"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
DWORD nData = sizeof(szPath);
if (RegQueryValueEx(hKey, _T("InstallPath"), 0, NULL, (LPBYTE)szPath, &nData) == ERROR_SUCCESS)
PathAppend(szPath, _T("FiregraphicXP.exe"));
RegCloseKey(hKey);
}
STARTUPINFO sui = { 0 };
PROCESS_INFORMATION pi = { 0 };
TCHAR szQuotedFileName[MAX_PATH];
if (PathIsDirectory(m_files[0])) // Browse with Firegraphic XP
{
TCHAR szCmdLine[MAX_PATH];
lstrcpy(szQuotedFileName, m_files[0]);
PathQuoteSpaces(szQuotedFileName);
lstrcpy(szCmdLine, _T(" "));
lstrcat(szCmdLine, szQuotedFileName);
if (CreateProcess(szPath, szCmdLine, NULL, NULL, FALSE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &sui, &pi))
{
CloseHandle(pi.hProcess);
return S_OK;
}
}
return E_INVALIDARG;
}
Hiu Sing Ngai
Firegraphic.com
|
|
|
|
|
On XP the shell invokes context menu extensions when you pick something from the lists on the left Explorer pane. At the beginning of InvokeCommand(), you're not checking pCmdInfo->lpVerb, so your code is running regardless of what menu item was picked (even if it wasn't yours). Check that value, and if it isn't 0, return E_INVALIDARG without doing anything. (It will be 0 for your own menu because lpVerb is a 0-based index telling you which of your menu items was picked; in other cases it's a shell ID or a string.)
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks Mike, you saved me lots of time.
|
|
|
|
|
Anyone happen to have the source ZIP file for this app? It's been removed from the MSDN site.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I have a ThemeExplorer sample from the Platform SDK on my HD. Is this the one you are after?
Michael
Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor
|
|
|
|
|
|
I want to use somthing like varible that need to be same value for the process. But different values for different processes. How can i do that?
I meant it needs to be in DLL ? Here the variable is single only.
VIKS
|
|
|
|
|
Like GetCurrentProcessId?
Btw, within that process it's not a variable, it's a constant.
|
|
|
|
|