Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
F

FreeCastle

@FreeCastle
About
Posts
24
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Windows Service
    F FreeCastle

    Well I think I can't really help you that much, but I also created a service some time ago. And I know that a service has to be created as a win32 console application, so I am wondering of how your application can work as a service (because it uses document/view architecture and consists therefore of a GUI). Because of that I think that you have some core logic in your application that works without a GUI. So you have to create a new console application for your service and put your "real" logic into that service. You can then rebuild your MFC app to access the logic in the service as a frontend (compare e.g. MSSQL Server: The "real" MSSQL server runs also as a service, but there exists also a frontend by which you can control this service). VC6 is very old now, and I would suggest to start every new project with a newer version. But because this is an older application and you use many other third party libraries for VC6 I would suggest to stay to VC6, just because then you maybe don't have that much problems...

    C / C++ / MFC c++ csharp com architecture question

  • GDI+ & MFC - Resizing problem
    F FreeCastle

    Ahhh thank you, that works. But anyway I have to put an Invalidate() into the OnSize handler, because without that I see the changes only after hiding and showing again the dialog. I don't really understand why this has to be done by a HDC, but the main thing is that it works. But there is one question open to me. In my "real" application I also do some transformations on the Graphics object (you know, for e.g. having a real local coordinate system and so on). Actually those transformations have only to be done when the dialog is showed the first time, and each time when the dialog is resized. But with that solution I also would have to make those transformations each time I draw my graphical objects. I don't really know, but I think this slows the performance a little bit down (and performance is important to me in this app). So is there a way to just recreate the Graphics object when the windows is resized (so that I don't have to perform all the time those transformations)? Anyway... thank you a lot!!

    C / C++ / MFC help c++ winforms graphics learning

  • GDI+ & MFC - Resizing problem
    F FreeCastle

    Yes I know that cx and cy will also work. But I wanted to be completely sure, so I used GetClientRectangle. The result is anyway the same. When I don't call "Invalidate" in the OnSize Handler then my dialog won't clear out the old contents (this will be then first done when I hide and show it again). Here is some example code (all placed in my simple dialog class): I have the following attributes: Graphics* m_Canvas; //the GDI+ Graphics object to draw some stuff RECT m_rcRect; //holds the actual client rectangle of the window And the following methods: OnPaint() { drawLines(); CDialog::OnPaint(); } OnSize(UINT nType,int cx, int cy) { CDialog::OnSize(nType,cx,cy); m_rcRect.bottom = cy; m_rcRect.right = cx; Invalidate(); } drawLines() { static bool bFirstCall = true; static Pen pen(Color::Red); if (bFirstCall == true) { m_Canvas = ::new Graphics(m_hWnd); bFirstCall = false; } m_Canvas->DrawLine(&pen,10,10,m_rcRect.right-10-10,10); m_Canvas->DrawLine(&pen,10,10,10,m_rcRect.bottom-10-10); }

    C / C++ / MFC help c++ winforms graphics learning

  • GDI+ & MFC - Resizing problem
    F FreeCastle

    Oh okay, I didn't say it right. To be exact, I get the client rectangle in the OnSize message handler, and then compute the new dimensions of the two lines. All I do then in the OnSize()-method is a call to Invalidate() and nothing else. The commands for drawing the two lines are placed in the OnPaint handler. And yes, the dimensions of the two lines are computed correctly for 100% sure. That's strange in addition: The resizing works correctly if I make the dialog smaller, but when I make the dialog bigger then the two lines don't get bigger starting from a certain size.

    C / C++ / MFC help c++ winforms graphics learning

  • GDI+ & MFC - Resizing problem
    F FreeCastle

    Hi, I am getting crazy with my problem, and I really hope that someone can help me out. Actually it sounds quite easy: I have a normal simple dialog, and I then draw 2 lines (like the axes of a coordinate system) in that dialog using GDI+. So far so good. When the user resizes my dialog I of course also want to apply the changes in size to my 2 lines. That means that they should always have the same margin to the dialog borders. And that's the problem. When I make the dialog bigger, then the lines don't get "longer" but they stay in the same length as before. But If I make the dialog smaller they also get smaller. Just strange. I do this by overriding the OnSize message handler of MFC and I then just get the client rectangle of the dialog and then draw the lines with this new rectangle applied. I also tested this with just a normal button instead of the GDI+ lines. With a normal button it works as it should, but when using GDI+ it doesn't work and I absolutley don't know why :( Many thanks for that person who can help me... P.S. I didn't know exactly in which forum to post it, because it may be a problem with MFC, but it also may be a problem with GDI+, so I just posted it in here, because I think that here are more readers...

    C / C++ / MFC help c++ winforms graphics learning

  • Socket question: When does a client connect to a server?
    F FreeCastle

    Ah thank you a lot, the first link was very informative. That DisconnectEx function looks cute, but I think I'll avoid it because it only runs on XP or higher. I think I use shutdown, and if I understood that article right, I have also to "create" the socket (by a call to socket(...)) again, when I want to "reuse" it for a new connection.

    C / C++ / MFC question sysadmin

  • Socket question: When does a client connect to a server?
    F FreeCastle

    Yes I know closesocket(), but I thought that there might be a better way, because when I call closesocket() then I also have to create the socket again, before calling the connect function. But anyway thank you both.

    C / C++ / MFC question sysadmin

  • Socket question: When does a client connect to a server?
    F FreeCastle

    Hmm yes I thought of something like this... But this yields in my next question: How can I disconnect from a server? I think there doesn't exist a command like disconnect(). So how is the best way to do this?

    C / C++ / MFC question sysadmin

  • Socket question: When does a client connect to a server?
    F FreeCastle

    Hi, I am using Winsock(only TCP) and I wondered when a client really connects to a server. With connecting I mean the whole process of establishing a TCP connection (that means Handshake, and so on). Is this done via the connect(...) function or is it every time done when the client sends data to the server by the send(...) function? The background of my question is, that I have a client app and I make a call to the connect() function when I initialize the client app. Now the user can choose between different actions, which asks the server for some data. That means, that there is only data send when the user chooses one of this actions; actually he can do nothing all the time. Is the way I do it okay, or would it be better to connect only to the server when the user chooses a specific action and then disconnect again (doing this then for every action)?

    C / C++ / MFC question sysadmin

  • Retrieving VARCHAR out of MSSQL with ADO
    F FreeCastle

    Yes that's of course a possibility, which means that I parse out the spaces behind the real string by hand. But I wondered if there wasn't any other possibility or if I made something wrong when getting this value from the database. But it seems that I made it correctly... that's just strange... Anyway thank you

    Database database c++ sql-server json help

  • Retrieving VARCHAR out of MSSQL with ADO
    F FreeCastle

    Hi, thanks for your reply. I did a mistake when posting the code in here. In fact I do it exactly the way you do it. But I have still this problem that there are a lot of spaces behind the "real" string. Any other ideas? I don't have a real idea.; it's just very strange...

    Database database c++ sql-server json help

  • Retrieving VARCHAR out of MSSQL with ADO
    F FreeCastle

    Hi I am using C++ and ADO to connect and retrieve data out of a MSSQL database (2005). I have a problem when executing simple queries like "SELECT MyText From MyTable" (whereas MyText would be a VARCHAR). For executing this query I use a record set like this: RecordSet->Open(...); if (!RecordSet->EndOfFile) { _bstr_t result = RecordSet->Fields->GetItem(_T("MyText"))->GetValue(); ... } After this, the result variable contains in fact a value for MyText in this table. But the problem is that it does not only contain the text of MyText but also many whitespaces behind. That means, that if MyText was e.g. a VARCHAR(100), I get the text of it and behind a sequence of spaces till my _bstr_t gets the length of 100. Is there any solution to this problem, except for parsing out the spaces behind my string by hand?

    Database database c++ sql-server json help

  • Deploy StoredProcedures written in C#/.NET
    F FreeCastle

    Hi, did you receive my email ?

    Database csharp question sql-server visual-studio sysadmin

  • Deploy StoredProcedures written in C#/.NET
    F FreeCastle

    Mh yes it helps again :-) But I think that I am somehow to stupid... I get always an error saying, that the return types of the t-sql- and clr-types aren't equal. I tried it e.g. this way: create function MyStoredProc(@name nvarchar(30)) RETURNS uniqueidentifier as external name [MyAssembly].[MyClass].[MyStoredProc] In my c#-code I see that the implemented storedprocedure MyStoredProc has an output parameter with type of SqlGuid (which is a uniqueidentifier (I think)). I have also another stored procedure that hasn't any output parameter, but which return value should I specify there ? NULL doesn't work

    Database csharp question sql-server visual-studio sysadmin

  • Deploy StoredProcedures written in C#/.NET
    F FreeCastle

    Hi, thank you that was helpful. But maybe I'm to stupid but it doesn't work correct for me. If I execute this e.g. in sqlcmd then I see the deployed assembly, but I don't see the Stored Procedures in my database (as I said I just see the deployed assembly). I tried this with a new clean database, but on my sql server I already have another database with the same assembly (and stored procedures). Could this be the reason that I don't see the Stored Procs in my first mentioned database ? (I think I heard time ago something like, that all Stored Procs are saved globally in the sql server)

    Database csharp question sql-server visual-studio sysadmin

  • Deploy StoredProcedures written in C#/.NET
    F FreeCastle

    Hi, as the title says it, I've a question about deploying such assemblies to the MSSQL Server (2005). I know that you can deploy it in Visual Studio, but I wondered if there isn't any other way to deploy them WITHOUT Visual Studio ? That would be very neat. Theoretically there must be some possibilities to do this. Maybe someone has experience with it and can give me some hints

    Database csharp question sql-server visual-studio sysadmin

  • Windows Service: Strange problem (crashes)...
    F FreeCastle

    Mh... I made a new project for my windows service and placed my real application code in there, and what shall I say.. it works perfectly. I just made some refactorings to my original windows service code... don't know why it works now. Anyway thank you for your help. I will remember that tip with the debugging.

    C / C++ / MFC help database performance

  • Windows Service: Strange problem (crashes)...
    F FreeCastle

    Hi, with the help of MSDN I wrote my own little (pure) Windows Service, that doesn't do anything. I also implemented the ability to install/uninstall this service in the service database. My problem now is, that if I want to start that service from the system control in windows it crashes with a well known error message like this: "The instruction at 0xnnnnnnn referenced memory at 0xnnnnnnn. The memory could not be written." I then wrote a simple logging-function, which prints the status information about my service to a file. And when I look at this file it seems that all is correct. All things are initialized and so on. And I also get to that point where the service's main function takes place, that means I get to the point where the real work of the service should take place. But as I said before, the service crashes while trying to start it up. That's a little strange to me. Maybe someone encountered a similar problem before or can give me some hint or help. That would be very nice. I know this description is a little bit vague, but it's not that easy because I can't figure out WHERE my service crashes. That's in fact my problem :( Ah I forgot to mention, that I am using WinXP. Maybe that's important...

    C / C++ / MFC help database performance

  • Win-Sockets / Unicode
    F FreeCastle

    Hey, thanks a lot. Now it's all clear to me. (sry for late reply)

    C / C++ / MFC question sysadmin

  • Win-Sockets / Unicode
    F FreeCastle

    Hey thanks. I've now done this at the sending client to copy the TCHARs to my sending buffer: memcpy(pPointerToBuffer,MyString,wcslen(MyString)*sizeof(TCHAR)) And at the server side I do something like this: int n = 10; //assuming that we know that this unicode string has a length of 10 TCHAR ReceivedString[n]; memcpy(ReceivedString,pPointerToBuffer,sizeof(TCHAR)*10); ... This works and I think it's correct. Or is there a better way to do this ? Again thank you

    C / C++ / MFC question sysadmin
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups