|
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
|
|
|
|
|
How to get icons of all currently opened windows(top-level, unowned) ?
|
|
|
|
|
You would enumerate all top level windows using ::EnumWindows( ) and given a handle to a window you can send it a WM_GETICON message.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
This is my code
HICON NewGetIcon(HWND p_hWnd) <br />
{<br />
<br />
HICON hIcon = NULL;<br />
HMODULE hInst = (HMODULE)GetClassLong(p_hWnd,GWL_HINSTANCE);<br />
hIcon = (HICON)::SendMessage(p_hWnd,WM_GETICON,ICON_SMALL,0);<br />
<br />
<br />
<br />
<br />
<br />
if (hIcon == NULL)<br />
hIcon = (HICON)GetClassLong(p_hWnd,GCL_HICONSM);<br />
<br />
if (hIcon == NULL)<br />
hIcon = (HICON)GetClassLong(p_hWnd,GCL_HICON);<br />
<br />
<br />
<br />
return (hIcon); <br />
} <br />
The problem is that it returns either not correct icon or empty icon (not NULL!)
Of course, I've different combiantions of commenting, uncommneting...
|
|
|
|
|
|
Hello All,
I am new to MFC - but have used C for around 3 years so I have the basics sorted out.
My question is I am trying to write my own saving routine and have created a SaveFile funtion in which I am using fwrite, to save information to a txt file - the problem being is it will save fine until the code reaches the line : saveArchive.Close(); in Doccore.cpp, this then clears the file.
Now being new to MFC Ihave learnt a fair amount on my own but cannot seem to solve this problem.
If this helps here is my code in my savefile function.
void CMy_newDoc :: SaveFile(const char *filename)
{
char buffer[255];
FILE *file = fopen (filename, "w+");
sprintf (buffer, "Text tobe saved into file");
fwrite( buffer, sizeof( char ), sizeof(buffer), file );
fclose(file);
}
Thanks in adavance for helping a newbie to MFC
|
|
|
|
|
The problem is that MFC has it's own code for persistence, and it is creating an empty file for you. You should look into iostreams ( which is standard C++ persistence code ) instead of using this C stuff, which is ugly and inflexible in comparison.
I'm not sure how to get the archive code to leave your file alone, but the way I usually do it is roll my own function in response to File/Save which brings up it's own CFileDialog and uses that path, that way MFC never gets to know where it is.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Are you use the doc/view architecture? If yes, make sure you disable serialization. Although I do not know how the framework knows what file to write to since you do saving inside of a separate function.
What calls function SaveFile(...)?
Kuphryn
|
|
|
|
|
Hey thanks guys for the quick respnse - its great to see that people are willing to help out, I try on OpenGL forums - now you have inspired me to try harder.
Anyway Christian - that thought totally escped me and I will go ahed and do it that way, thanks - just a small question hwo do i then capture what file has been enterd into the file box?
kuphryn - i am calling the saving code from
void CMy_newDoc::Serialize(CArchive& ar)
{
int ok;
CString filename;
filename = ar.GetFile()->GetFileName();
if (ar.IsStoring())
{
// TODO: add storing code here
SaveFile(filename);
}
Thanks again for the help
|
|
|
|
|
Implement handlers for Save and Save File As instead of called the save function from inside Serialize().
Kuphryn
|
|
|
|
|
Dinner@6 wrote:
just a small question hwo do i then capture what file has been enterd into the file box?
If you create your own CFileDialog, you can call GetFile(), or GetPath(). Something like that.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
You're basically overriding the overall Document/View architecture in MFC if you write your own archiving streams. CArchive is an already opened archive stream, wired up by MFC, CDocument and CFileDialog (to get the file name to save to.) All you have to do in Serialize is use the C++ insertion/extraction operators to get data into and out of the file:
void CMy_newDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << buffer;
}
else
{
ar >> buffer;
}
}
If your data is stored in a class, you can derive it from CObject , and override the Serialize method to store class-specific data. That way you can use the C++ insertion/extraction operators on an object instance:
class CMyObject : public CObject
{
protected:
int m_nOne;
float m_fTwo;
CString m_strData;
public:
CMyObject() : m_nOne(0), m_fTwo(0.0) { }
int GetOne(void) const { return m_nOne; }
void SetOne(int n) { m_nOne = n; }
float GetTwo(void) const { return m_fTwo; }
void SetTwo(float f) { m_fTwo = f; }
LPCTSTR GetData(void) const { return m_strData; }
void SetData(LPCTSTR s) { m_strData = s; }
DECLARE_SERIAL(CMyObject)
virtual void Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << m_nOne << m_fTwo << m_strData;
}
else
{
ar >> m_nOne >> m_fTwo >> m_strData;
}
}
};
IMPLEMENT_SERIAL(CMyObject, CObject, VERSIONABLE_SCHEMA | 1)
void CMy_newDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << m_oMyObj;
}
else
{
ar >> m_oMyObj;
}
}
There you go. CDocument 's OnSaveDocument() and OnOpenDocument() (which you don't have to mess with) end up calling CDocument's base class CObject::Serialize . CObject reference[^] Here's an MFC Object Serialization referance[^]
-- ian
http://www.ian-space.com/
|
|
|
|
|
I want to use CImage to save a dib as a jpg file. However,
whenever I save it produces a black rectangle. Any suggestions?
Here is my code:
CImage img;
int h = 292;
int w = 248;
// Create a dib section
img.Create(w, h, 8);
// Get a DC and draw in it (a red rectangle)
HDC hdc = img.GetDC();
RECT r;
r.top = r.left = 0;
r.bottom = h;
r.right = w;
HBRUSH br = ::CreateSolidBrush(RGB(255,0,0));
::FillRect(hdc, &r, br);
// Release the DC
img.ReleaseDC();
// now save the image
img.Save("c:/temp/testimg.jpg", Gdiplus::ImageFormatJPEG);
I get a black rectangle file with the correct dimensions.
I am sure I am doing something dumb, but any help would be
appreciated.
TIA.
|
|
|
|
|
If CImage is a GDI+ class ( I don't remember, but it looks like it, I thought it was just called Image ), then you need to select it into a Graphics object and draw on it there.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Hi, I'm trying to create a simple Listbox, using Win32, no MFC.
void CreateSpilList()
{
ProgramList = CreateWindow (TEXT ("listbox"), NULL,
WS_CHILD | WS_VISIBLE | LBS_STANDARD,
5, 5,
100,
100,
hwnd, (HMENU)10,
GetModuleHandle(NULL),
NULL) ;
}
I've created a simple function that should create the listbox.
case WM_CREATE:
{
CreateSpilList();
break;
}
The WM_CREATE Message should create my Listbox, but it wont, nothing happens.
But, the strange thing is, if i remove CreateSpilList(); and inserts whats in the function:
like so.
case WM_CREATE:
{ ProgramList = CreateWindow (TEXT ("listbox"), NULL,
WS_CHILD | WS_VISIBLE | LBS_STANDARD,
5, 5,
100,
100,
hwnd, (HMENU)10,
GetModuleHandle(NULL),
NULL) ;
break;
}
It works, why can't I create my listbox by using a function like my CreateSpilList() ???
It make no sense, even if i inline the CreateSpilList() nothing happens.
Can anyone give me an answer on this strange "bug" ??
Thanks
|
|
|
|
|