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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
H

HJo

@HJo
About
Posts
15
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Previously focused control
    H HJo

    That should do the trick! But how do I add the Leave event to all controls? Do I have to loop through all controls and add it one by one, or is is possible to add an event to a collection? (Doesn't seem to be possible with ControlsCollection) Thanks! /Henrik

    C#

  • Previously focused control
    H HJo

    Hi all, I wonder if there is some way to find out which control had input focus previously to an other... I.e. from a btn_Click(...) event handler, I want to know which control had focus before the user clicked the button. Thanks in advance, /Henrik J.

    C#

  • Translate this method to c++;
    H HJo

    This function does not compile in C# (bad parameter in recursive call), and as far as I can see it doesn't do anything useful (it always return false). If you fix that, I might be able to help you.

    C / C++ / MFC c++ csharp help

  • Object reference not set to an instance of an object.
    H HJo

    Thank you for your reply! There is no need to create an instance, since the methods are declared static. I'm sure GetLiveList() is declared dllexport in the dll. The C++ code was a header file used when importing the dll into C++ code, which I have used as a model for my C# interface. The problem turned out to be the difference of the long data type between C++ and C#: C++ long is 4 bytes whereas C# long is 8 bytes and C# int is 4 bytes. So the solution was to replace all occurences of long in the interface with int. :) Regards, /Henrik

    C# csharp c++ question

  • Object reference not set to an instance of an object.
    H HJo

    Hi, I am trying to create a C# interface for a dll with functions. The C++ interface for one of the functions looks like this: __declspec(dllimport) long _cdecl GetLiveList( long, long*, long*, long[]*, long); I declared my C# equivalent as: public class Ismbus32 { //... [DllImport("ismbus32.dll", CharSet=CharSet.Auto, CallingConvention=CallingConvention.Cdecl)] private static extern long GetLiveList( long, ref long, ref long, ref long[], long); } When I try to call the function, using the code below, I get a NullPointerException and the message "Object reference not set to an instance of an object." public class Form1 : System.Windows.Forms.Form { //... private void btn_Click(object sender, System.EventArgs e) { long in = 2; long out1 = 0; long out2 = 0; long[] items = new long[635]; long itemsMax = 634; long lRes = Ismbus32._CDDLG_GetLiveList(in, ref out1, ref out2, ref items, itemsMax); } } Does anyone have a clue?! Thanks in advance, /Henrik Johansson

    C# csharp c++ question

  • More templates problems
    H HJo

    What is wrong with (.h) Member* get_member(Book* book); (.cpp) template<class Book,class Member> Member* AssociationList::get_member(Book* book) { ... } ?

    C / C++ / MFC c++ database wpf algorithms data-structures

  • Prepend a letter to a char array using ASCII
    H HJo

    strcat() example from MSDN: /* STRCPY.C: This program uses strcpy * and strcat to build a phrase. */ #include #include void main( void ) { char string[80]; strcpy( string, "Hello world from " ); strcat( string, "strcpy " ); strcat( string, "and " ); strcat( string, "strcat!" ); printf( "String = %s\n", string ); } Output: String = Hello world from strcpy and strcat!

    C / C++ / MFC ios game-dev data-structures help tutorial

  • Disappearing folders in Visual Studio
    H HJo

    The folder information is stored in the project's .opt file, so you'll need to protect if from beeing removed or overwritten. Or, if you're using a version control system, you could have it checked in, checking it out when you make changes to the class tree... I don't know why they disappear, but it's bothering me as well.

    C / C++ / MFC csharp visual-studio help question

  • Pointer to pointers
    H HJo

    This is one way of doing it... struct BinaryFunction { double (*eval)(double, double); char* sign; }; double add(double a, double b) { return (a+b); } double subtract(double a, double b) { return (a-b); } int main(int argc, char* argv[]) { BinaryFunction** ppBFunctionList = new BinaryFunction*[2]; char addSign[] = " + "; BinaryFunction Add = { &add, addSign }; ppBFunctionList[0] = &Add; char subSign[] = " - "; BinaryFunction Sub = { &subtract, subSign }; ppBFunctionList[1] = ⋐ for (int i = 0; i < 2; i++) { double dRes = (*ppBFunctionList[i]->eval)(3, 2); printf("%.2f\n", dRes); } return 0; } Regards, /Henrik J

    C / C++ / MFC question

  • how to terminate the loop containing scanf?
    H HJo

    Yes. If you don't want to wait for enter, you should read one character at a time, e.g. getchar(). Example from MSDN: /* GETC.C: This program uses getchar to read a single line * of input from stdin, places this input in buffer, then * terminates the string before printing it to the screen. */ #include void main( void ) { char buffer[81]; int i, ch; printf( "Enter a line: " ); /* Read in single line from "stdin": */ for( i = 0; (i < 80) && ((ch = getchar()) != EOF) && (ch != '\n'); i++ ) buffer[i] = (char)ch; /* Terminate string with null character: */ buffer[i] = '\0'; printf( "%s\n", buffer ); }

    C / C++ / MFC tutorial question

  • how to terminate the loop containing scanf?
    H HJo

    Does it have to be scanf()? Otherwise you could gets(), which terminates at Ctrl+Z: int i = 0; char a[10][10]; while (gets(a[i]) != NULL) { i++; }

    C / C++ / MFC tutorial question

  • Add-in questions...
    H HJo

    Hi all, I have a question regarding DevStudio add-ins: Is it possible to enable/disable, or even change, buttons in an add-in command bar? If it is - how? Thanks, /Henrik

    C / C++ / MFC question

  • Which container should i choose
    H HJo

    I guess you could use a hash table of some kind, but I don't have any good samples on that now. You could also try using a std::map. There is a sample in MSDN if you look at map::find().

    C / C++ / MFC graphics sysadmin docker help question

  • Creation of User DSN
    H HJo

    From the top of my head there are a couple of ways to do it: - SQLDriverConnect() in the ODBC API - CDatabase::Open() / OpenEx() It is probably possible to get it from other database APIs as well... Hope it helps!

    C / C++ / MFC c++ tools question

  • Clear OutputWindow from Add-in?
    H HJo

    Does anyone know how to clear all text from the macro tab in the Output Window from a DevStudio Add-in?

    C / C++ / MFC tutorial question
  • Login

  • Don't have an account? Register

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