|
SetLayeredWindowAttributes is only supported on Windows 2000 or greater therefore you will not see it on an older operating system. If you are building for windows 2000 or greater, you will need to define _WIN32_WINNT = 0x0500, otherwise the preproocessor will remove all of the API definitions that are only available on Windows 2000 and above. Coincidentally this will cause runtime error if you run one of these programs on a system that has an older DLL version.
As far as linking a library to your project, you can do it the way that you specified, or you can go to the linker tab of your projects settings, and add the name of the lib to your project. However most likely you are already linking user32.lib into your program if your program already has a user interface.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
QUESTION 1:
#define _WIN32_WINNT = 0x0500
and why? It's not in the api documentation??
QUESTION 2:
What do I type in project>setting>"link" tab>"object/library module" ??
"./user32.lib"
Is this right? Do I have to include quotation mark?
QUESTION 3: I downloaded a sample that uses LoadLibrary.
# define LWA_COLORKEY 1
# define LWA_ALPHA 2
# define WS_EX_LAYERED 0x80000
HWND hWnd=this->m_hWnd;
typedef DWORD (WINAPI *PSLWA)(HWND, DWORD, BYTE, DWORD);
PSLWA pSetLayeredWindowAttributes;
HMODULE hDLL = LoadLibrary ("user32");
pSetLayeredWindowAttributes = (PSLWA) GetProcAddress(hDLL,"SetLayeredWindowAttributes");
if (pSetLayeredWindowAttributes != NULL) {
pSetLayeredWindowAttributes(this->m_hWnd, RGB(255,255,255), 100, LWA_COLORKEY|LWA_ALPHA);
}
It claims that the code wont crash even if run on Win98 or platform that doesnt support SetLayeredWindowAttributes and transparency.
U think it's a good idea?
norm
|
|
|
|
|
btw, i've got the code working via LoadLibrary. it's more versatile too.
i'm still interested to see how to statically linked library to your module via project>setting>link tab
norm
|
|
|
|
|
Hi.
Okay. I would like to ask a question that I know is quite popular among MFC Windows developers. It holds the key to some very cool GUI features when implemented correctly.
I would like to know, How do you resize and reposition objects inside of a CFormView (apply to resizable dialog box as well) as the user resizes the main frame? For example, given there is an edit view inside a formview. As the user resizes the frame, I would like to the expand or contract the edit box. Another example in the same scenario is repositioning the entire edit box or a button according to how the user resizes the formview.
Thanks,
Kuphryn
|
|
|
|
|
The frame/view receive a WM_SIZE message, you handle it, and use MoveWindow on each controls ( objects ) to their new position and size, or look around here on codeproject, people already did some auto-position/size classes that do that automatically.
Personally, I use resizing sparingly, I try to build my UI in a way that the default size is good for the data to be inputed or viewed. resizing doesn't give "more" to the user.
Max.
|
|
|
|
|
|
Just out of curiousity, what is the difference between MoveWindow() and SetWindowPos()?
Kuphryn
|
|
|
|
|
MoveWindow sends other messages, WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED, WM_MOVE, WM_SIZE, and WM_NCCALCSIZE. SetWindowPos does not.
I prefer MoveWindow because I can handle those messages so I can manage the sizing myself of the child windows.
Max.
|
|
|
|
|
|
Hi guys:
Does anyone know where IE stores the information in the History popup window, what the format of that file is, and under what conditions it's possible to change it. (or is it?) Basically I want to change what's displayed in-place... I was thinking of just subclassing that window, but a cleaner way would be to change the file itself... any ideas?
Thanx
----------------------------------------
----I said my name wasn't important
---------------------------SlartiBartFast
|
|
|
|
|
No guru here, it's newbie stuff. The history is of course a tree folder with internet shortcuts. To get it without hardcoding a path (changing depending on the OS), use the shell API ::SHGetFolderPath with CSIDL_HISTORY as parameter.
How low can you go ? (MS rant)
|
|
|
|
|
If you want manipulate the history, you should use the IUrlHistory[^] interface to do it properly.
-- ian
"The greatest danger to humanity is humanity without an open mind." - Ian Mariano
http://www.ian-space.com/
|
|
|
|
|
Hi again:
Thanks for the responses. A couple questions:
1. I need this to work for IE5, and according to MSDN the IUrlHistory interfaces require 5.5 minimum.
2. The History "folder" is kind of weird -- I have a strong suspicition it's actually a file, shown as a folder through the use of shell extensions, or something like that. In other words, I don't think I can just enum files inside that folder, looking for ones I want to change. Am I wrong?
Any other ideas?
Thanks,
Gene
----------------------------------------
----I said my name wasn't important
---------------------------SlartiBartFast
|
|
|
|
|
I'm working on a GINA replacement, because we need to do some custom log on of the users.
I have one major problem that I can't find any solutions for.
When the user is logged on, the start-menu is, err..., not exactly disabled but it's acting very strage.
Fucus is not folloving the mouse, and it don't respond to mouse clicks.
Anyone got an idea?
I have been searching google and found other people with the same problem, but not any solutions.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Are you sure you setup proper security descriptors for the WinSta0 and WinSta0/Default windowstation/desktop objects?
Seems that the user account the shell process is running under has not the proper access rights to create menus.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
I found this a couple of hours ago, and it did the trick
TOKEN_GROUPS *pGroups;
DWORD dwSize, i;
BOOL status = FALSE;
pGroups = (_TOKEN_GROUPS*)LocalAlloc(LMEM_FIXED, 2048);
GetTokenInformation(pgContext->UserToken, TokenGroups, pGroups, 2048, &dwSize);
for (i = 0; i < pGroups->GroupCount; i++)
{
if ((pGroups->Groups[i].Attributes & SE_GROUP_LOGON_ID) == SE_GROUP_LOGON_ID)
{
CopySid(GetLengthSid(pLogonSid), pLogonSid, pGroups->Groups[i].Sid );
break;
}
}
LocalFree(pGroups);
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I'm using the CHtmlCtrl from this article http://www.microsoft.com/msj/0100/c++/c++0100.asp[^] so I can put the CHtmlView in my dialog based app and it works fine except for one problem. When I load my app the CHtmlCtrl sits in a state of disarray, what I mean is the ctrl just flashes bars of the form color and doesn't load anything until I click a menu item. Once I do that the page loads and all is well until the CHtmlCtrl gets covered by another window then the whole things starts again. Here's the code I'm using to paint the window:
CWnd* pParent = GetParent ();
CRect rect;
pParent->GetWindowRect (&rect);
pParent->ScreenToClient (&rect);
MoveWindow (&rect, TRUE);
I want the CHtmlCtrl to be resized to the size of the window that's why I'm using the code above. If I take out the code above then the CHtmlCtrl isn't updated until a menu item is clicked. I'm completely baffled as to what the menu items are calling besides the OnPaint handler that is making the page load correctly. Any help would be very much appreciated. If you want anymore code or information just let me know.
Thanks in advance.
- monrobot13
|
|
|
|
|
are you moving the window inside the OnPaint handler?
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
Chris Losinger wrote:
are you moving the window inside the OnPaint handler?
Yes, the code I gave above is the code for my OnPaint handler.
- monrobot13
|
|
|
|
|
try putting that MoveWindow outsite the OnPaint handler. otherwise, you're probably causing paint messages from inside your OnPaint handler. while it's not recursive, it's more painting than you need.
-c
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
Thanks. That got rid of the bars going all crazy but I still have to click a menu in order to get anything to show.
- monrobot13
|
|
|
|
|
Hi,
I'm to C ++/mfc and I'm trying to modify a chat program to have the capability to transfer files as well as messages.
I found help from with code to send the file from this forum, but when I implemented it, I keep getting an error, "Unknown error while accessing unnamed file".
I put a button on the client side, and when the person clicks on it, the file dialog box is supposed to open, and the person can choose the file to send.
I get the dialog box, but I get the error right after I choose the file.
I put messages throughout the code to see where the progran has reached, and it seems to be going through fine! I'm really confused!!
I'm pasting the code below. If anyone has any idea what I'm doing wrong please respond.
-------------------------------------------------
void CMainFrame::OnSFile()
{
MessageBox("File Transfer");
CSocket cSocket;
cSocket.Create();
cSocket.Connect((LPCTSTR(m_strServerIP)),m_iFTPort);
CSocketFile sf(&cSocket);
CArchive ar(&sf, CArchive::store);
/*code for CFileDialog goes here*/
static char BASED_CODE szFilter[] = "All Files (*.*)|*.*||";
CString strPath;
CFileDialog m_ldFile(TRUE,".*","*.*",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);
// Initialize the starting directory
//m_ldFile.m_ofn.lpstrInitialDir = _T("C:\\");
// Show the file open dialog and captures the result
//if IDOK
if (m_ldFile.DoModal() == IDOK)
{
strPath = m_ldFile.GetPathName();
CFile myFile(strPath,
CFile::modeRead | CFile::typeBinary);
MessageBox("here");
//get file info
DWORD length = myFile.GetLength();
MessageBox("here2");
char *data = new char[length];
MessageBox("here3");
myFile.Read(data, length);
MessageBox("here4");
//send it across
ar << myFile.GetFileName();
ar << length;
ar.Write(data, length);
delete[] data;
myFile.Close();
}
MessageBox("here5");
}
----------------------------------------------------------------
|
|
|
|
|
Hi.
I created a class called COGLwindow which is essentially a simple opengl rendering window. It is implemented using the familiar WIN32 approach. It has its own event handler (WNDPROC). For now, all that it does is render a simple scene. My problem is this:
I spawn a COGLwindow window (for now) from a simple AppWizard generated SDI application. After the window is created and the scene is rendered, I seem to lose contact with the COGLwindow event handler. Specifically, I have to send the COGLwindow window into the background and reactivate (bring to the foreground) it, in order for it to respond to window messages again. I can't even click in the main application's space. I have to either activate another application or click on the taskbar to reactivate the window. After this procedure, everything seems to work fine.
Any Suggestions as to what's wrong here?
ks
|
|
|
|
|