|
The probem is not the const.
const unsigned char Sawtooth[] = {0,1,2,3,4,5,6,7,8,9};
If you try ...
Sawtooth[0] = 1;
...you'll see the compiler won't let you.
Passing Sawtooth as a const unsigned char * will work as well.
The assignment shown above won't work as you've seen - you need to deep-
copy the array contents from one to the other. Note if the destination is const
you won't be able to unless you cast away the const.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Dear gurus/colleagues:
Anybody knows what Win32 API function I can use to verify if a user account is already a member of a local or domain group?
I am working on a Oracle OS Authentication project. The user account I am talking about is for example: <domain_name>\<user_name> or <machine_name>\<user_name>.
The group I am talking about is for example: ORA_SEND_ALMUSER
I want to be able to use a Win32 API function to call and pass in the GROUP NAME as well as USERNAME to see if the username is a member of the groupname?
Any help would be greatly appreciated.
|
|
|
|
|
Hi,
I am designing a series of MFC controls for inputting basic information into a DirectX Modeling program. I would like to make those controls widely available by publishing them on this (or some similar) site. This is my first time doing this, so before I put them out there for feedback and general use, I thought I'd get some input on what design patterns would be easiest or most conventional to use.
Basically I am working on a control that will allow a user to input parameters for the following basic DirectX meshes:
Polygon (2 params)
Box (3 params)
Sphere (3 params)
Cylinder (5 params)
Torus (4 params)
Text (3 params)
and it's materials (10 params, or one struct).
So as you can see this control will contain a lot of information. Should I allow the user to access this material through one giant struct or wrapper class containing all the data, or by memberwise retrieval? Should the user gain access to the data by references or by values?
Any references on MFC control design patterns appreciated.
Thanks - Jason
|
|
|
|
|
how do i open a CStdioFile for writing such that i dont loose my previous data that exists in this file??
CStdioFile file;
file.Open("Temp1.dat",CFile::mode????);
????-> i tried using modeNoTruncate, modeReadWrite , but may be thats not the solution!!
|
|
|
|
|
OK i tried using the following and it worked. If any body has a better solution then please suggest:
CString line_feed='\x00A';<br />
CStioFile file;<br />
file.Open("Temp1.dat",CFile::modeReadWrite);<br />
file.SeekToEnd();file.WriteString(line_feed);<br />
CString str="watever u want to put";<br />
file.WriteString(str);<br />
file.Close();
|
|
|
|
|
Hello,
I have setting a background image into a ListCtrl with SetBkImage() method.
But the image is showed with a scroll, like the texts in the rows.
How could I disable the scroll of the background image? I hope to put the image fixed in the background of ListCtrl.
Any idea?
Thanks,
Cris.
|
|
|
|
|
|
I am working on an application that has the ability to open files using MFC and Visual Studio .Net 2003. I need give the user the option not to continue opening the file for special cases or scenarios. The determination is based on a keyword setting in an XML tag. Using the Serialize method, I was able to modify the software to not continue loading the file. However, it loaded it anyways but not completely. Do you know how I can prevent it from loading a file completely?
|
|
|
|
|
Have your Serialize method throw a CArchiveException. This will cause CDocument to totally cleanup the partially loaded file.
AfxThrowArchiveException(CArchiveException::none);
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Well, i need to execute a function at the change of day(or possibly a time defined by user). I have used CWnd::SetTimer()at one place for 5 secs trigerring. How can i do it to trigger every day(or hour)...i dont think it would be advisable to plainly convert a day's value into milliseconds and pass it to SetTimer()!!! What way can i achieve this??
|
|
|
|
|
It looks like SetTimer has a maximum interval of 24.85 days (if I did the math correctly).
Hours or a day shouldn't be a problem.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Just think of how many milliseconds are lost each day, I would go for QueryPerformanceCounter but then some say the MM timers are better :p
|
|
|
|
|
|
Why don't you just make use of windows' Task Scheduler?
|
|
|
|
|
Task scheduler?? i dont know anything about it...
Right now i have used SetTimer() for 6lac count; that's 10 mins....
do you think there could be a problem using SetTimer()???
|
|
|
|
|
Hi,
I am trying to resize 2 CButtons at runtime, but am having a really hard time getting them to appear in the correct place.
GetWindowRect gives me values that are offset to the dialog. To demonstrate, the code i am using is something like the following;
<br />
CRect btnRect;<br />
btn1.GetWindowRect(btnRect);<br />
<br />
::SetWindowPos(btn1.m_hwnd, btnRect.left, btnRect.top, btnRect.Width(), btnRect.Height(), SWP_SHOWWINDOW); <br />
This results in the button moving diagonally across the screen, it doesnt stay still, which is what I would have expected. I find that if i take away (rectDialog.left + 3) and (rectDialog.top + 29) from btnRect.left and .top it will work (stay still).
I assume the '3' is the width of the boarder, and '29' the height of the title bar. Is this correct?
If so, how can I find it programatically?
Thank you very much for your help.
|
|
|
|
|
SetWindowPos coordinates for child windows are relative to the client
area of the parent window.
You are using window coordinates relative to the screen.
Try GetClientRect instead of GetWindowRect.
What Roger said
Also, MoveWindow is simpler and more appropriate for this than SetWindowPos.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
MapWindowPoints() or ScreenToClient()
CRect btnRect;
btn1.GetWindowRect(btnRect);
ScreenToClient(&btnRect); //assumes that this is the parent of btn1
btn1.SetWindowPos(wndTop, btnRect.left, btnRect.top, btnRect.Width(), btnRect.Height(), SWP_SHOWWINDOW);
|
|
|
|
|
I need someone with Orcas to test the following code. It compiles just fine under Comeau C++ 4.3.9 in strict mode (Comeau is supposedly the "most Standards-compliant compiler in existence") but fails with an error under VS.NET 2003 (VC++). According to the ANSI Standard (section 10.3.5 in my Draft copy), I can't find any reason for it to fail.
class MyBase
{
public:
MyBase() {}
virtual ~MyBase() {}
virtual MyBase *Copy() const
{
return new MyBase(*this);
}
};
class MyBase2
{
public:
MyBase2() {}
virtual ~MyBase2() {}
virtual MyBase2 *Copy() const
{
return new MyBase2(*this);
}
};
class MyDerived : public MyBase, public MyBase2
{
public:
MyDerived() {}
virtual ~MyDerived() {}
virtual MyDerived *Copy() const
{
return new MyDerived(*this);
}
};
int main()
{
return 0;
}
|
|
|
|
|
|
I don't have Orcas installed and really don't want to risk messing up my main build environment, which is a pretty delicate setup. Dropping a new compiler on the system is the general equivalent of a tactical nuclear warhead. I want to know if the bug is in Orcas (i.e. emits an incorrect error message). Please, just run it through Orcas and post the output.
|
|
|
|
|
I know you didn't ask, but it works fine in 2005.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks. I'll just assume it works fine in VS 2008 as well.
|
|
|
|
|
another problem
In my menu I use checked option. The problem is how to change the checked/uncheked mark when I click on it and also send the value to some variable (true if checked, false if unchecked).
Program is MFC based on CFormView.
Hope you understand my problem......
|
|
|
|
|
Hi barbarini,
Use the GetMenuItemInfo() API call to get the menu item's state, you can then tell if it's checked or not.
regards,
|
|
|
|