• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About dathui

  • Rank
  1. GUI

    I've got this idea for a game that i'd like to throw together, the problem is that it needs a gui with a few graphic effects. I tried ogre3d with CEGui but my laptop almost died from running the sample, so does anybody know any gui libraries that doesn't requite as much but does provide some widgets and possibility to add my own effects?
  2. problems with EditBox

    thanks alot, will look into both of these problems.
  3. Lately i've been working on a little wrapper for gui-handling in windows and it all went fine until i tried to implement textboxes. Labels, lists and buttons didn't pose any problems but with editboxes they refuse to enter any chars. Since other types of controls work perfectly i'm kind of clueless. I have dug around a little bit on msdn but nothing i've found has worked. Here's my code, i've tried to cut out parts that shouldn't matter. CEdit.cpp CEdit::CEdit(std::tstring& text, uint32 x, uint32 y, uint32 height, uint32 width, IWindow* parent, bool pswfield, int styles) : IWindow(parent) { int usedstyles = WS_CHILD | WS_VISIBLE | ES_LEFT | styles; m_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), usedstyles, x, y, width, height, m_parent, (HMENU)m_id, GetModuleHandle(NULL), NULL); if(m_hwnd == NULL) globals::printError(_T("CEdit::CEdit()"), __TFILE__, __LINE__, GetLastError()); setOnCommand(makeOnCommand(CEdit, *this, &CEdit::defOnCommand)); parent->addChild(this); } --------------------------------------------------------------------------- CWindow.cpp LRESULT CALLBACK tools::win32::wndProcProxy(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { window_it it = windows.begin(); while(it != windows.end()) { if(hwnd == (*it)->getHWND()) { LRESULT retr = (*it)->wndProc(hwnd, message, wParam, lParam); ++it; return retr; } else ++it; } return (BOOL)DefWindowProc(hwnd, message, wParam, lParam); } int CWindow::handle(MSG& msg) { //is this window the reciever? if(msg.hwnd == m_hwnd) { if(wndProc(msg.hwnd, msg.message, msg.wParam, msg.lParam) == 0) return Window_MessageHandled; return Window_MessageNotHandled; } //it's not this window, check if a childwindow is the reciever if(m_children.size() > 0) { child_it it = m_children.begin(); while(it != m_children.end()) { if(IsDialogMessage((*it++)->getHWND(), &msg)) return Window_MessageHandled; } } return Window_MessageNotHandled; } LRESULT CALLBACK CWindow::wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CREATE: case WM_SIZE: case WM_DROPFILES: case WM_KEYDOWN: { (*m_onKeyDown)(wParam, lParam); } break; case WM_COMMAND: { child_it it = m_children.begin(); while(it != m_children.end()) { int32 id = (*it)->getID(); uint32 p = LOWORD(wParam); if((*it)->getID() == LOWORD(wParam)) { (*(*it)->getOnCommand())(wParam, lParam); break; } else ++it; } } break; case WM_DESTROY: default: return (BOOL)DefWindowProc(m_hwnd, message, wParam, lParam); } return 0; } ----------------------------------------------------------------------------- win32main.cpp int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { MSG msg; string cmdline(lpszArgument); //calling main if(!app->start()) return -1; //messageloop while(GetMessage(&msg, NULL, 0, 0) > 0) { TranslateMessage(&msg); bool handled = false; WindowCollection::window_it it = WindowCollection::windows.begin(); while(it != WindowCollection::windows.end()) { if((*it)->handle(msg) == Window_MessageHandled) //for one of our windows { handled = true; break; } else ++it; } if(!handled) DispatchMessage(&msg); } // The program return-value is 0 - The value that PostQuitMessage() gave return (int)msg.wParam; } ----------------------------------------------------------------------------- main.cpp class App : public Application { public: bool start() { window = new CWindow(string("mickes app")); if(window->create(100, 100, 350, 350, 0) == 0) return false; edit = new CEdit(string("test"), 250, 50, 25, 50, window); return true; } private: CWindow* window; CEdit* edit; }; Application* win32::app = new App;
  4. compiling generated code

    yea that's what i meant with using cl.exe and link.exe, it's the windows version of what you said. What i'm wondering is if there's another way.
  5. What would be the easiest way to generate executable files from a file? say i got my generator.exe and depending on input want to compile either #include <iostream> int main() { std::cout <<"Foo" <<endl; } or #include <iostream> int main() { std::cout <<"Bar" <<endl; } One way would be to just generate a source-file and then using cl.exe and link.exe from the visual toolkit, but i wonder if there's another way.
  6. nope LRESULT CALLBACK CWindow::wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CREATE: (*m_onCreate)(lParam); break; case WM_SIZE: (*m_onSize)(wParam, lParam); break; case WM_DROPFILES: { vector<string> files; char filename[MAX_PATH]; HDROP hdrop = (HDROP)wParam; int numFiles = DragQueryFile(hdrop, -1, NULL, 0); for(int a = 0; a < numFiles; ++a) { if(DragQueryFile(hdrop, a, filename, MAX_PATH) > 0) { files.push_back(filename); } } (*m_onDragDrop)(files); } break; case WM_KEYDOWN: { (*m_onKeyDown)(wParam, lParam); } break; case WM_COMMAND: { child_it it = m_children.begin(); while(it != m_children.end()) { if((*it)->getID() == LOWORD(lParam)) { (*(*it)->getOnCommand())(wParam, lParam); break; } } } break; case WM_DESTROY: (*m_onDestroy)(); break; default: return (BOOL)DefWindowProc(hwnd, message, wParam, lParam); } return 0; } edit: fixed it, my proxy function returned 0 so you led me on the right path. thanks alot for the help.
  7. i'm trying to put together a little framework for making handling the win32 api easier, but i can't get the CreateWindowEx to work properly. here's the create function, m_hwnd becomes null and GetLastError returns 183, or "Cannot create a file when that file already exists.", which i simply don't understand. I've tried changing m_title(set in the ctor) but it doesn't help. int CWindow::create(uint32 x, uint32 y, uint32 height, uint32 width, int resourceID, int styles, IWindow* parent) { WNDCLASSEX wincl; /* Data structure for the windowclass */ m_regTitle = m_title; /* The Window structure */ wincl.hInstance = ThisInstance;; wincl.lpszClassName = m_title.c_str(); wincl.lpfnWndProc = wndProcProxy; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof(WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor(NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) { TCHAR* buff = new TCHAR[256]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buff, 256, 0); MessageBox(NULL, buff, "Error", MB_OK); delete[] buff; return 0; } m_hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ m_title.c_str(), /* Classname */ m_title.c_str(), /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ width, /* The programs width */ height, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ ThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); if(m_hwnd == NULL) { //stringstream ss; //ss <<"Error: " <<GetLastError() <<endl; //MessageBox(NULL, ss.str().c_str(), "Error", MB_OK); TCHAR* buff = new TCHAR[256]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buff, 256, 0); MessageBox(NULL, buff, "Error", MB_OK); delete[] buff; return 0; } ShowWindow (m_hwnd, TRUE); WindowCollection::windows.push_back(*this); return (int)(m_hwnd != NULL); } Thanks in advance
  8. selected hex?

    ah, thanks alot...that's the problem with homegrown algos, there's usually a professional that has done the same thing with about 5% of the cpu ;)
  9. I've been thinking abit about selection of hexagons with a mouse. finding the right one using squares is easy, so i thought if you use squares and triangles as the base for hexagons you could get the selected hexagon. Is there any easier way of doing this?
  10. OO in AS?

    ok, thanks for the reply. will probably try to integrate AS in my little project soon.
  11. OO in AS?

    A while ago i checked out ASs homepage and it seemed like they didnt have OO yet, but on the articles page there's an article named "Polymorphism in AngelScript"..so does AS have OO or not? (by have OO i mean can you write classes in scripts and inherit new classes from old ones)
  12. shortest path

    I'm working on a shortest path-function for a project. I have been wondering if i should use A* for this so i decided to ask here. It has to find the shortest path on a board of around 10x10 tiles with the same cost for all tiles and impassible walls. I've been thinking of some algo that would pick the right direction first and try it out and if those doesnt work the side-directions.
  13. you can't do it that way, what you can do is make a ibasefunc-class, and then inheritd globalfunc, memberfunc etc from that one. then your function take an ibasefunc as an argument. short example: //abc for func returning R template<class R> class IBaseFunc { public: virtual ~IBaseFunc(){} virtual R operator()() const = 0; }; //template for memberfunc to class C returning R template<class C,class R> class CMemFunc : public IBaseFunc<R> { public: typedef R (C::*F)(); CMemFunc(C& obj,F func) : m_obj(&obj) ,m_func(func){} virtual R operator()() const { return (m_obj.*m_func)(); } inline virtual C& getObj() { return m_obj; } inline virtual F getFunc() { return m_func; } inline virtual void setObj(C& obj) { m_obj = &obj; } inline virtual void setFunc(F func) { m_func = func; } CMemFunc& operator=(const CMemFunc& rhs) { } private: C* m_obj; F m_func; }; //helperfunction for creating a CMemFunc template<class C, class R> IBaseFunc<R>* memFunc(C& obj,R (C::*f)()) { return new CMemFunc<C,R>(obj,f); } and then your function would just take a IBaseFunc*
  14. Simulate network

    I am terribly sorry, it seems i really can't make myself clear. Say a program on node a runs send("foo","2.43.5") which should send "foo" to 2.43.5. What i want help with is how to design the network itself. How node a sending "foo" knows to which node out of a list {b,c,d,e} to send the packets to if they are just going to 2.43.5. Should it send to all nodes and they only recieve it if the ip-adresses match(easy but ineffecient), or some more efficient solution? Interesting idea with the automatic-file adding thou, will ponder on that one later, thanks alot :)
  15. Simulate network

    Apparently my first post wasn't that good so i'll make another attempt. I have class A that is basicly a simplified computer with hdd, files and folders, programs and some other things computers have. Now i'm thinking of how to add "internet" to my simulated computer, so programs running on these computers can talk to each other thru this network. My problem is that i don't know how to structure/design the network part. Should i have a class B that know all the ips and just send it to the correct one (lookup-time increasing with each new node) or some other strucutre?
  • Advertisement