|
Oliver123 wrote: In Ladder.h- I declare a function and set up a structure
void WalkLadderUpDown(struct PriceLadder TransPL);
Are you sure that is in your definition of the Ladder class?
Are you getting other errors? I suspect that if you have other errors and fix them, then this one that you are asking about will go away.
|
|
|
|
|
Everything works Ok if all structures and functions are confined to one class.
The problem arises when I put the function into class-B and call it from class-A. I can call any other class-B function from class-A. And I can use references to int and doubles in passing params to a class-B function from class-A. But when I try to pass a structure as either a stand alone or a reference the compiler says it can't convert the class-A structure to a class-B structure.
The same structure is defined in both class-A and class-B. ???
|
|
|
|
|
Hi,
I think my subject says most of it. I am a little stuck with this problem. What must I do if I want e.g. send a few normal chars and then an Integer ? I think I must somehow pack it all into a byte array. But how ? Hope someone can help me. Thanks
|
|
|
|
|
something like this?
BYTE bytes[100];
int anInt = 10, anotherInt = 50;
char *str = "Hi there";
BYTE *pPos = bytes;
memcpy(pPos, anInt, sizeof(int));
pPos += sizeof(int);
strcpy(pPos, str, strlen(str));
pPos += strlen(str);
memcpy(pPos, anotherInt, sizeof(int));
pPos += sizeof(int);
|
|
|
|
|
copying an integer value inside a byte array (an array of unsigned char, I suppose) is simple, for instance:
int i=5;
unsigned char buff[0x100];
memcpy((void*)buff, (void *)&i, sizeof(i));
but you must be aware that INTEL processors have little-endian byte order, while TCP/IP network has big-endian one.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi,
thanks that helped me. I already thought that it's something like memcpy. But there's my next question. How can I get then from this byte array the original values back ?
Btw when I send data with TCP/IP, do I have to send it was unicode (TCHAR) or normal (unsigned char) ?
|
|
|
|
|
FreeCastle wrote: I get then from this byte array the original values back
if you, at the opposite side of the TCP line, don't know what is the nature of the data contained inside the byte array then you are lost. So maybe you have to preceede each chunk of data with, say, a marker section (maybe few bytes) that state:
(1) the type of the following items
(2) the lenght of the following items
Hey, you're establishing a protocol!
FreeCastle wrote: Btw when I send data with TCP/IP, do I have to send it was unicode (TCHAR) or normal (unsigned char) ?
When you are sending bulk data maybe BYTES (hence unsigned char) are more appropriate.
hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hey thanks a lot again. And you're right, I am writing in fact a little protocol
|
|
|
|
|
Hello,
I am working with an on-screen keyboard that was designed from scratch using the Win32 API, and it designed to be used with 4 or 5 languages. The keyboard works absolutely perfectly except when attempting to display some of the special characters for the other forgein languages(characters above 0x7F on the ASCII table). When I attempt to print these characters using the WM_CHAR message, the following character ÿ always appears before it.
For example:
If I were to press the "A" key, the edit box above the keyboard display "A". However, if I press the "Ö" button on the onscreen keyboard, the edit box about the keyboard displays "ÿÖ". I am totally stumped and was hoping anyone could provide any insight into why this is happening.
Thanks in advance,
Joe
|
|
|
|
|
Post some relevant code, both where you send the WM_CHAR message and where you are recieving it. Are you doing UNICODE builds?
ÿ is ascii 0xff, that should tell you something, but without seeing the code I can not tell you what.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I will try to post some code tomorrow, however, the keyboard procedure is pretty large, so I will try to post some relevent pieces.
|
|
|
|
|
can you help me to find the ps2(6 pin) port interfacing by visual c++
please help me
than you
ahmad al-omar
|
|
|
|
|
Hi,
I've a list control I need to add some functionality to. Currently, this list stores two fields - a string field and a long.
Whenever the original programmers went searching for a single item in the list, to update that list, they searched for the string - the 0th element column - whereby FindItem returns the index val (row) of the item.
I need add a column when the app is init'd. Fine, ok. I have now a string, a long and another long(my new column).
I need to be able to search for that new column such that column 0 and column 2 return as a unique indexed item.
Base Question: How do I search for a sub-item in a CListCtrl?
Thanks, in advance.
C
|
|
|
|
|
I think you may have to iterate over the subitems and try to match/search them yourself. I do not know of a built-in way to search by sub-item.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I'd really appreciate it if someone could look at these header files and give me some idea how to fix them. Basically what I have is a tic-tac-toe program in MFC. I have a main window, which is class CGameWin (inherits from CFrameWnd) and a dialog box class called CGameKeyBindingDialog (inherits from CDialog). Previously I did almost everything in CGameWin, and everything worked out fine. Then CGameWin got bloated with functions that were related to game mechanics rather than graphics or window handling, so I decided to create the class GameOperations. It does everything for the game not related to graphics or window handling. That's when everything got hosed up. Here are the class related errors I'm getting:
e:\Homework\CS\CS2\Game\game_interface.h(14): error C2011: 'CGameKeyBindingDialog' : 'class' type redefinition
e:\Homework\CS\CS2\Game\game_interface.h(29): error C2011: 'CGameWin' : 'class' type redefinition
e:\Homework\Cs\Cs2\Game\game_operations.cpp(50): error C2065: 'CGameWinPtr' : undeclared identifier
e:\Homework\Cs\Cs2\Game\game_interface.cpp(16): error C2065: 'Operations' : undeclared identifier
e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP messageMap 1' : redefinition
e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP CGameKeyBindingDialog::messageMap' : redefinition
e:\Homework\Cs\Cs2\Game\game_interface.cpp(352): error C2086: 'const AFX_MSGMAP_ENTRY _messageEntries 0[]' : redefinition
e:\Homework\Cs\Cs2\Game\game_interface.cpp(382): error C2086: 'const AFX_MSGMAP_ENTRY CGameKeyBindingDialog::_messageEntries[]' : redefinition
game_interface.h:
#ifndef GAME_INTERFACE_H
#define GAME_INTEFRACE_H
#include <afxwin.h>
#include "game_operations.h"
#include <defenitions.h>
using namespace std;
class CGameWin;
class CGameKeyBindingDialog : public CDialog
{
public:
CGameKeyBindingDialog(char* lpszName);
BOOL OnInitDialog();
CGameWin* getMainWnd();
void setMainWnd(CGameWin* mp);
void InitAll();
afx_msg void OnExitDialog();
private:
CGameWin* m_pMainWnd; //pointer to main window
DECLARE_MESSAGE_MAP()
};
class CGameWin : public CFrameWnd
{
public:
CGameWin();
~CGameWin();
void PopMessageBox(LPCSTR Message, LPCSTR Title, UINT Style);
afx_msg void OnPaint();
//input handling
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//file menu "File"
afx_msg void OnNewGame();
afx_msg void OnExit();
//graphics
void RedrawScreen(CDC* Surface, int MouseOverPosition, bool MouseOver);
void DrawXOs();
void DrawMouseOvers(int Position, MouseOverType MouseOver);
void DrawBitmaps();
void RefreshOffSet();
//game stuff
int ConfirmExit();
PlayerType GetPlayerSide();
private:
//classes
CGameKeyBindingDialog CGameKeyBindingDialog;
GameOperations Operations;
//graphics
CDC grid_DC; //grid memory device context
CDC xo_DC; //xos memory device context
CDC buffer_DC; //buffer device context
CBitmap CBitGrid;
CBitmap CBitXO;
CBitmap CBitBackBuffer;
int OffSetX;
int OffSetY;
void DrawMonoLine(CDC* Surface, int srcX, int srcY, int destX, int destY);
void DrawCircle(CDC* Surface, int srcX, int srcY, int Diameter);
void DrawSquare(CDC* Surface, int srcX, int srcY, int Side);
//brushes and pens
void InitBrushPen();
void DeleteBrushPen();
CPen BlackPen;
CPen XGreenPen;
CPen OBluePen;
CPen RedErrorPen;
CPen DashBoxGreenPen;
CPen DashBoxBluePen;
DECLARE_MESSAGE_MAP()
};
#endif
game_interface.cpp, CGameWin constructor:
CGameWin::CGameWin() : CGameKeyBindingDialog("CKeyboardDialog") : GameOperations("Operations")
{
Create(NULL, "Tic-Tac-Toe", WS_OVERLAPPEDWINDOW,
rectDefault, NULL, "Game");
CGameKeyBindingDialog.setMainWnd(this);
Operations.SetPtrToMainWindow(this);
OffSetX, OffSetY = 0;
InitGrid();
CBitGrid.CreateBitmap(150, 150, 1, 32, NULL);
grid_DC.CreateCompatibleDC(NULL);
grid_DC.SelectObject(CBitGrid);
buffer_DC.CreateCompatibleDC(&grid_DC);
xo_DC.CreateCompatibleDC(&grid_DC);
CBitXO.CreateCompatibleBitmap(&grid_DC, 150, 100);
CBitBackBuffer.CreateCompatibleBitmap(&grid_DC, 400, 400);
InitBrushPen();
DrawBitmaps();
Operations.SetPlayerSide(GetPlayerSide());
}
game_operations.h:
#ifndef GAME_OPERATIONS_H
#define GAME_OPERATIONS_H
#include <defenitions.h>
#include "game_interface.h"
using namespace std;
class GameOperations
{
public:
GameOperations();
~GameOperations();
void InitGrid();
bool ConfirmLegalMove(GridStateType NewState, int GridX, int GridY);
void PlaceXorO(CPoint MousePosition, PlayerType CurrentSide);
void SetPlayerSide(PlayerType NewSide);
PlayerType ReturnPlayerSide();
void SetPtrToMainWindow(CGameWin* NewPtr);
protected:
GridSquareType Grid[3][3];
private:
CGameWin* PtrToMainWindow;
PlayerType PlayerSide;
};
#endif
I know I'm asking a lot, but I'd really appreciate any help.
|
|
|
|
|
game_interface.h #includes game_operations.h
and
game_operations.h #includes game_interface.h
looks like you need to remove that circular dependency: either move declarations around or use forward declarations (like you do with "class CGameWin;"), to get rid of the need to do that circular include.
|
|
|
|
|
Try this (I'll just post the related changes in the header files)...
#ifndef GAME_INTERFACE_H
#define GAME_INTEFRACE_H
#include <afxwin.h>
#include "game_operations.h"
#include <defenitions.h>
using namespace std;
class CGameKeyBindingDialog : public CDialog
{
#ifndef GAME_OPERATIONS_H
#define GAME_OPERATIONS_H
#include <defenitions.h>
class CGameWin;
using namespace std;
class GameOperations
{ In game_operations.cpp, include in this order
#include "game_operations.h"
#include "game_interface.h"
|
|
|
|
|
Thank you. Got it working now. Just got to finish the AI and put in some eye candy and it should be ready.
|
|
|
|
|
I am having a problem getting my D3DFonts to display antialiased. No matter what font I try to use, although some are better than others, it comes out all jagged around the edged like is is not being antialiased properly or at all.
Font creation code:
if (FAILED(D3DXCreateFont(m_pDirect3D->GetDevice(),
iSize,
0,
iWeight,
0,
bItalic,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
stFace,
&font.m_d3dFont)))
{
return -1;
}
Font Display Code:
m_pDirect3D->GetFontSprite()->Begin(D3DXSPRITE_ALPHABLEND);
m_vFonts[state.m_nFont].m_d3dFont->DrawText(m_pDirect3D->GetFontSprite(),
state.m_stText,
-1,
&rPos,
state.m_dwTextJustify | DT_WORDBREAK,
D3DCOLOR_RGBA(red,green,blue,iOpacity));
m_pDirect3D->GetFontSprite()->End();
I have tried drawing both with a Direct3D sprite and by setting the first parameter to NULL.
Any help is always appreciated.
Thanks,
Dustin
P.S. Here is a link to what it looks like : http://img238.imageshack.us/img238/4011/fontsamplecl4.jpg[^]
-- modified at 12:54 Wednesday 20th December, 2006
|
|
|
|
|
Dear all,
I make a windows explorer like application using MFC.
If the folder content was changed by other application.
How to make my application know when to refresh its folder view ?
Thank's
|
|
|
|
|
|
If your application is going to be manipulating directories as well (creating, deleting, renaming items), be sure to use the SHChangeNotify(...) function to notify the shell, if necessary.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I constantly add more data into a CEdit, i also activated the scroll bar for this window.
When the text exceeds the CEdit text area limit, the scroll bar is activated so i can scroll the text up and down which is good.
Though instead of that i have to scroll downwards to see the new text added, is there a CEdit function which tells the scroll bar to always stay at max, or point downwards? So i have to scroll upwards instead to see the old text.
Thanks
|
|
|
|
|
Hi Fredrick,
I think there is no direct way. Though you could call something like this
CEdit myEdit;
CString csContent = _T("");
myEdit.GetWindowText( csContent );
myEdit.SetSel( csContent.GetLength(),
csContent.GetLength(),
TRUE );
.. every time you add new text to your edit control.
|
|
|
|
|
Hi Robert
How do i focus it to the correct idc? i get an assert:
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar);
if (!bNoScroll)
this is the code i have:
void CAutoUpdaterDlg::OnUpdateScreen()
{
char LocalBuffer[10];
itter++;
sprintf(LocalBuffer, "%d", itter);
CEdit * p = static_cast<cedit *="">(GetDlgItem(IDC_Window));
// static message for now
if(!FilesInProgress)
{
strcat(WindowBuffer, LocalBuffer);
strcat(WindowBuffer, ": ");
}
else
strcat(WindowBuffer, "");
strcat(WindowBuffer, DynamicBuffer);
int Size = strlen(WindowBuffer);
p->SetMargins(5,5);
p->SetWindowText(Convert_A_To_DA(WindowBuffer));
CProgressCtrl * progress = static_cast<cprogressctrl *="">(GetDlgItem(IDC_PROGRESS));
progress->SetRange(0,MaxRange);Progress++;
progress->SetPos(Progress);
int MemSize = strlen(DynamicBuffer);
for(int i = 0; i<= MemSize+1; i++)
{
DynamicBuffer[i] = 0x00;
}
CEdit myEdit;
CString csContent = _T(Convert_A_To_DA(WindowBuffer));
myEdit.GetWindowText( csContent );
myEdit.SetSel( csContent.GetLength(),
csContent.GetLength(),
TRUE /* scroll to the selected text */ );
UpdateWindow(); FilesInProgress = false;
}
|
|
|
|
|