|
Under Win95, Win98 you can directly write the hex-value to the port (with assembler):
...
void outportb(unsigned int portid, unsigned char value)
{
__asm
{
mov edx, portid
mov al, value
out dx, al
}
}
...
outportb(0x378, 20);
...
Under NT-Systems, like Win2000, WinNT and XP you are not allowed to write directly to the ports.
It this case just use a port-driver like "UserPort" (just take a look on http://www.mattjustice.com/parport/par_nt.html).
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hello!,
I am a little stuck with this piece of code, can anyone help me please?
Actually I don’t know how to implement the assignment operator and the overloaded operator. Can you give me some tips and ideas please. As it is apparent, I have just started with C++ programming.
//file myString.h
#include
class myString
{
private:
char* theString;
int length;
public:
myString();
myString(char*);
~myString();
myString(const myString&);
myString(const char*);
//the assignment operator
myString& operator=(const myString&);
myString& operator=(const char*);
int getLength();
const char* GetString();
// == operator overloaded for string comparison
friend int operator==(const myString&, const myString&);
friend int operator==(const myString&, const char*);
};
Thanks
|
|
|
|
|
I am not sure what you mean by the overload operator?
As far as the assignment operator, this is what you need to do:
1: check for a reference to the current object. There is no sense in reassigning of you are doing something like this:
Object A;
A = A;
Here is the code you use to do that check:
myString &operator=(const myString& rhs)
{
if (*this == rhs)
{
return *this;
}
...
}
2: delete all of your existing memory, to prevent memory leaks.
delete[] theString;
theString = NULL;
3: allocate and copy the data from the input parameters.
if (rhs.theString)
{
length = strlen(rhs.theString) + 1;
theString = new char[length];
strcpy(theString, rhs.theString);
}
4: Returns a reference to this object to make things like this possible:
Object A, B, C;
...
A = B= C;
Here is the code to do this:
return *this;
Good Luck
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!
|
|
|
|
|
Hi
Thanks for the reply, i think you are the only person who was able to reply to my problem. I am actually working on string manipulation and i have been provided the myString.h file. Thanks a lot,
|
|
|
|
|
I think that a lot of people skipped over your post because they perceived it as your homework assignment. Many students come here and post questions that basically ask someone from CP to do their assignment for them. Just be sure to ask for help in a way that lets people know you are trying to learn and are willing to the work yourself except that you are stuck.
Good Luck
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!
|
|
|
|
|
Thanks,
It's just that the operator and assignment operator part that kept me stuck, of course i was trying. thanks for the help.
|
|
|
|
|
Sorry for my English , it is not my own language.
I write a program which draw and move a triangels. When i move i must a redraw area. I use double buffering. I use MDI.
When i moving, after a several time colours are disappears. If i want draw
something i write:
CBrush *brush = new CBrush(m_cColour);
CPen *lpPen = new CPen(PS_SOLID,2,(m_bSelected)?RGB(150,100,50):RGB(0,0,0));
pDC->SelectObject(lpPen);
//Draw
delete brush;
delete lpPen;
May be i must free somethings(resourece) another way.
Please Help.
|
|
|
|
|
when you select an object into a DC, you must de-select it before you destroy the DC or the object. you do this by selecting the default object back into the DC:
CBrush brush;
brush.CreateSolidBrush(...);
CBrush *pOldBrush = dc.SelectObject(&brush);
...
dc.SelectObject(pOldBrush);
-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
|
|
|
|
|
I cannot find the APIs on MSDN...
|
|
|
|
|
UuidCreate()
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hello!
Mr. Dunn is correct. Alternatively, you could use the following code to get a standard CString that contains a new GUID:
GUID l_GUID;
::CoCreateGuid(&l_GUID);
OLECHAR szGUID[40];
::StringFromGUID2(l_GUID, szGUID, 39);
CString sGUID = szGUID;
Hope that helps!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
|
I made a MFC extension DLL and it works fine. However, I have one exported class there that is built from another class. THus in the include it has included the header to that other class. However, I do not want to export that "other" class. So far I just exported it so that the program will work. Is there a way around it so that I don't have to export this "other" class?
THanks.
|
|
|
|
|
You only have to export a class, function or variable if you want to import it (use it) in a separate dll or executable. The only way that you will be exporting your class is if you declare it with the __declspec(export) compiler option, or if you have added a def file entry for that class.
Otherwise you can include as many class and function definitions in the main header and they will not be accessible. So if that parameter is defined for your class and it should continue to work and not be exported (as long as it resides in the same DLL that it is trying to be used from).
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!
|
|
|
|
|
if use CSocket to connect to a remote server through internet, is an ip address in text format, i.e. sss33-23.jfgh.com.au the same as the one in number format, i.e. 2222.22.22.22?
thx
includeh10
|
|
|
|
|
No. Use the gethostbyname() function to convert a name address (abc.def.com) to its IP address (12.34.56.78).
Software Zen: delete this;
|
|
|
|
|
The only thing i can choose in the toolbox dialog under general is the pointer. Anyone know what could be wrong?
Thanks
|
|
|
|
|
open or create a project first. This helps...;P
How low can you go ? (MS rant)
|
|
|
|
|
hi,
I've three questions:
1-How to change boutton color?
2-How to use the horisental bar in a liste boxe, despite a activate when the text bypasse width of the list boxe it still remains deactivated?
3-how to use the progression bar? ( give me an example if it is psossible )
very urgent, I need reply befor tomorrow if you can.
|
|
|
|
|
|
LOL
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
His english sounds like from a french guy. Now it makes me sad.
How low can you go ? (MS rant)
|
|
|
|
|
sorry for my english,
I've three questions:
1-How to change button color?
2-How to use the horizontal bar in a list box, despite I activate it ,when the text bypass the width of the list box the bar is still deactivated?
3-how to use the progression bar? ( give me an example if it is psossible )
|
|
|
|
|
In a MDI application I have a CFormView (called CListForm) associated with a IDD_FORMVIEW dialog type which I use as a template for a docking bar (used to show some thumbnails). The IDD_FORMVIEW dialog simply contains a CListCtrl. In CMainFrm.cpp, CMainFrame::OnCreate() is used to create every toolbar and even my thumbnails docking bar.
// This bar is derived from CSizeBar 2.44 by Cristi Posea
CViewBar m_wndImageBar;
CRuntimeClass* m_pRuntimeClass;
m_pRuntimeClass = RUNTIME_CLASS (CListForm);
m_wndImageBar.Create(this,
m_pRuntimeClass,
(CCreateContext *)(lpCreateStruct->lpCreateParams),
"Images", WS_CHILD | WS_VISIBLE | CBRS_TOP,
AFX_IDW_CONTROLBAR_FIRST + 33));
The problem is how to access to CListForm from CMainFrm.cpp because now I have to populate the list with a list of bitmap pointers using a CListForm member function I called PopulateList(). I tried to create a pointer to CListForm object in this way:
CListForm* m_pListForm;
m_pListForm = (CListForm*)m_pRuntimeClass->CreateObject();
m_pListForm->PopulateList();
Object is correctly created and shown in my MDI application and its member variables correctly allocated but its hWnd handle points to NULL!!! WHY?!? Infact when PopulateList() calls this function:
CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_LIST_CTRL);
to refer to its child CList control, it crashes.
Which is the correct way to fully access to my CListForm from CMainFrame class?
Thx
|
|
|
|
|
Have you tried GetActiveView( )? This function is a member of CFrameWnd so you should have access to it in your CMainFrame class. Note that you'll have to typecast the return value to CListForm*
Hope this helps.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|