Neither one nor Many

 
November 26 2010

There are a few things I figured out how to do, and I seem to use them on a regular basis. For these snippets I have to search through my projects every now and then, to find them, and it would be a lot easier if I kept them somewhere listed. Hopefully you will find something useful as well.

Clearing a sizer

I usually make master/detail screens where the detail list is a vertical sizer with stuff on it. Usually a panel with more stuff on it. Every now and then you may want to clear it. I use:

while (theSizer->GetChildren().GetCount() > 0) {
    theSizer->GetItem(static_cast<size_t>(0))->DeleteWindows();
    theSizer->Remove(0);
}

// populate the sizer again maybe

sizerChangelogItems->Layout();

You might want to surround the code with Freeze() and Thaw() for performance.

Hiding and showing a panel on an AUI frame

This is more of a note I keep forgetting about: Instead of calling the Hide() and Show() on the window (panel) itself (which compiles). Use the following:

someWindow->GetAuiManager().GetPane(someWindow->splitterwindow1).Show(false);
someWindow->GetAuiManager().GetPane(someWindow->panel1).Show(true);

someWindow->GetAuiManager().Update();

Using dropdowns with object data.

I use wxChoice a lot, I especially like that the items themselves can refer to anything. Typically how I initialize a choicebox:

wxChoice *choice = ...;
Object *someObject = ...;
for (...) {
    choice->Append("object 1", (void *)someObject);
}
choice->SetStringSelection("object 1");

Then usually I have an event that triggers on the selection of an item in the choicebox. In the event I first get the wxChoice, then cast the client data for the selected item to the object pointed to:

void SomeWindow::OnChoiceSelected( wxCommandEvent& event )
{
    wxChoice *choice = static_cast<wxChoice *>(event.GetEventObject());
    Object *someObject = static_cast<Object *>(choice->GetClientData(choice->GetSelection()));
    if (someObject != NULL) {
        //...
    }
}

Directory functions

wxString resdir(RESOURCE_DIR);
if (!::wxDirExists(resdir)) {
    throw std::runtime_error("resources dir not found");      
}
wxDir dir(resdir);
if ( !dir.IsOpened() ) {
    throw std::runtime_error("resources directory could not be opened");
}
wxString filename;
bool cont = dir.GetFirst(&filename);
while ( cont ) {
    int lastdot = filename.Find('.', true);
    if (lastdot != wxNOT_FOUND) {
        wxString name(filename.SubString(0, lastdot - 1));
        wxString ext(filename.SubString(lastdot + 1, filename.Length()));
        if (!ext.compare(_T("cpp"))) {
            ...
        } else {
            ...
        }
    }
    cont = dir.GetNext(&filename);
}

Write to file function

wxFile article(markdownfilename, wxFile::write);
if (!article.IsOpened()) {
    throw std::runtime_error("main.md could not be opened for writing");
}
article.Write(textctrlArticleBody->GetValue());
article.Close();
C++ Comments (190)

1

website: http://www.example.com @

2026-06-28 18:32:29

555

1

website: http://www.example.com @

2026-06-28 18:32:29

555

1

website: http://www.example.com @

2026-06-28 18:32:29

555

1mDTMmYcM

website: http://www.example.com @

2026-06-28 18:32:30

555

1

website: http://www.example.com @

2026-06-28 18:32:30

555

-1 OR 5*525 --

website: http://www.example.com @

2026-06-28 18:32:30

555

-1 OR 5*526 --

website: http://www.example.com @

2026-06-28 18:32:30

555

-1 OR 5*525

website: http://www.example.com @

2026-06-28 18:32:30

555

-1 OR 5*526

website: http://www.example.com @

2026-06-28 18:32:30

555

-1' OR 5*525 --

website: http://www.example.com @

2026-06-28 18:32:30

555

-1' OR 5*526 --

website: http://www.example.com @

2026-06-28 18:32:30

555

-1" OR 5*525 --

website: http://www.example.com @

2026-06-28 18:32:30

555

-1" OR 5*526 --

website: http://www.example.com @

2026-06-28 18:32:31

555

-1' OR 5*525 or 'Y9tiMuBW''

website: http://www.example.com @

2026-06-28 18:32:31

555

-1' OR 5*526 or 'Y9tiMuBW''

website: http://www.example.com @

2026-06-28 18:32:31

555

-1" OR 5*525 or "Sfdd7nxX""

website: http://www.example.com @

2026-06-28 18:32:31

555

-1" OR 5*526 or "Sfdd7nxX""

website: http://www.example.com @

2026-06-28 18:32:31

555

1*if(now()sysdate(),sleep(15),0)

website: http://www.example.com @

2026-06-28 18:32:31

555

10'XOR(1*if(now()sysdate(),sleep(15),0))XOR'Z

website: http://www.example.com @

2026-06-28 18:32:31

555

10"XOR(1*if(now()sysdate(),sleep(15),0))XOR"Z

website: http://www.example.com @

2026-06-28 18:32:32

555

(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

website: http://www.example.com @

2026-06-28 18:32:32

555

2

website: http://www.example.com @

2026-06-28 18:32:32

555

1-1; waitfor delay '0:0:15' --

website: http://www.example.com @

2026-06-28 18:32:33

555

1-1); waitfor delay '0:0:15' --

website: http://www.example.com @

2026-06-28 18:32:33

555

1-1 waitfor delay '0:0:15' --

website: http://www.example.com @

2026-06-28 18:32:33

555

1AU82p4bL'; waitfor delay '0:0:15' --

website: http://www.example.com @

2026-06-28 18:32:34

555

1-1 OR 214(SELECT 214 FROM PG_SLEEP(15))--

website: http://www.example.com @

2026-06-28 18:32:34

555

1-1) OR 757(SELECT 757 FROM PG_SLEEP(15))--

website: http://www.example.com @

2026-06-28 18:32:34

555

1-1)) OR 528(SELECT 528 FROM PG_SLEEP(15))--

website: http://www.example.com @

2026-06-28 18:32:34

555

14Na0q8bP' OR 407(SELECT 407 FROM PG_SLEEP(15))--

website: http://www.example.com @

2026-06-28 18:32:35

555

1LjqKSvhM') OR 625(SELECT 625 FROM PG_SLEEP(15))--

website: http://www.example.com @

2026-06-28 18:32:35

555

1pHuoZ2TB')) OR 142(SELECT 142 FROM PG_SLEEP(15))--

website: http://www.example.com @

2026-06-28 18:32:35

555

1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

website: http://www.example.com @

2026-06-28 18:32:36

555

1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

website: http://www.example.com @

2026-06-28 18:32:36

555

1

website: http://www.example.com @

2026-06-28 18:32:36

555

1'"

website: http://www.example.com @

2026-06-28 18:32:36

555

website: http://www.example.com @

2026-06-28 18:32:36

555

@@atRn9

website: http://www.example.com @

2026-06-28 18:32:36

555

(select 198766*667891)

website: http://www.example.com @

2026-06-28 18:32:36

555

(select 198766*667891 from DUAL)

website: http://www.example.com @

2026-06-28 18:32:37

555

1

website: http://www.example.com @

2026-06-28 18:32:37

555

1

website: http://www.example.com @

2026-06-28 18:32:37

555

1

website: http://www.example.com @

2026-06-28 18:32:38

555lHGL5NsR

1

website: http://www.example.com @

2026-06-28 18:32:38

555

1

website: http://www.example.com @

2026-06-28 18:32:38

-1 OR 5*525 --

1

website: http://www.example.com @

2026-06-28 18:32:38

-1 OR 5*525

1

website: http://www.example.com @

2026-06-28 18:32:38

-1' OR 5*525 --

1

website: http://www.example.com @

2026-06-28 18:32:38

-1" OR 5*525 --

1

website: http://www.example.com @

2026-06-28 18:32:38

-1' OR 5*525 or '4pDJmPn1''

1

website: http://www.example.com @

2026-06-28 18:32:38

-1" OR 5*525 or "oZCIAKps""

1

website: http://www.example.com @

2026-06-28 18:32:38

555*if(now()sysdate(),sleep(15),0)

1

website: http://www.example.com @

2026-06-28 18:32:39

5550'XOR(555*if(now()sysdate(),sleep(15),0))XOR'Z

1

website: http://www.example.com @

2026-06-28 18:32:39

5550"XOR(555*if(now()sysdate(),sleep(15),0))XOR"Z

1

website: http://www.example.com @

2026-06-28 18:32:39

(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

1

website: http://www.example.com @

2026-06-28 18:32:40

2

1

website: http://www.example.com @

2026-06-28 18:32:40

555-1; waitfor delay '0:0:15' --

1

website: http://www.example.com @

2026-06-28 18:32:41

555-1); waitfor delay '0:0:15' --

1

website: http://www.example.com @

2026-06-28 18:32:41

555-1 waitfor delay '0:0:15' --

1

website: http://www.example.com @

2026-06-28 18:32:42

555t6KZt6QH'; waitfor delay '0:0:15' --

1

website: http://www.example.com @

2026-06-28 18:32:42

555-1 OR 542(SELECT 542 FROM PG_SLEEP(15))--

1

website: http://www.example.com @

2026-06-28 18:32:42

555-1) OR 807(SELECT 807 FROM PG_SLEEP(15))--

1

website: http://www.example.com @

2026-06-28 18:32:42

555-1)) OR 745(SELECT 745 FROM PG_SLEEP(15))--

1

website: http://www.example.com @

2026-06-28 18:32:42

555w96wQOyp' OR 500(SELECT 500 FROM PG_SLEEP(15))--

1

website: http://www.example.com @

2026-06-28 18:32:43

555d2y8tqMt') OR 716(SELECT 716 FROM PG_SLEEP(15))--

1

website: http://www.example.com @

2026-06-28 18:32:43

555RfLR7LBK')) OR 452(SELECT 452 FROM PG_SLEEP(15))--

1

website: http://www.example.com @

2026-06-28 18:32:43

555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

1

website: http://www.example.com @

2026-06-28 18:32:44

555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

1

website: http://www.example.com @

2026-06-28 18:32:44

555

1

website: http://www.example.com @

2026-06-28 18:32:44

555'"

1

website: http://www.example.com @

2026-06-28 18:32:44

1

website: http://www.example.com @

2026-06-28 18:32:45

@@u9g3e

1

website: http://www.example.com @

2026-06-28 18:32:45

(select 198766*667891)

1

website: http://www.example.com @

2026-06-28 18:32:45

(select 198766*667891 from DUAL)

1

website: http://www.example.com @

2026-06-28 18:32:45

555

1

website: http://www.example.com @

2026-06-28 18:32:46

555

1

website: http://www.example.com @

2026-06-28 18:32:46

555

1

website: http://www.example.com @

2026-06-28 18:32:50

555

1

website: http://www.example.com @

2026-06-28 18:32:51

555

1

website: http://www.example.com @

2026-06-28 18:32:51

555

1

website: http://www.example.com @

2026-06-28 18:32:51

555

1

website: http://www.example.com @

2026-06-28 18:32:52

555

1

website: http://www.example.com @

2026-06-28 18:32:52

555

1

website: http://www.example.com @

2026-06-28 18:32:52

555

1

website: http://www.example.com @

2026-06-28 18:32:52

555

1

website: http://www.example.com @

2026-06-28 18:32:52

555

1

website: http://www.example.com @

2026-06-28 18:32:54

555

1

website: http://www.example.com @

2026-06-28 18:32:54

555

1

website: http://www.example.com @

2026-06-28 18:32:54

555

1

website: http://www.example.com @

2026-06-28 18:32:54

555

1

website: http://www.example.com @

2026-06-28 18:32:54

555

1

website: http://www.example.com @

2026-06-28 18:32:54

555

1

website: http://www.example.com @

2026-06-28 18:32:55

555

1

website: http://www.example.com @

2026-06-28 18:32:55

555

1

website: http://www.example.com @

2026-06-28 18:32:55

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:56

555

1

website: http://www.example.com @

2026-06-28 18:32:57

555

1

website: http://www.example.com @

2026-06-28 18:32:57

555

1

website: http://www.example.com @

2026-06-28 18:32:57

555

1

website: http://www.example.com @

2026-06-28 18:32:58

555

1

website: http://www.example.com @

2026-06-28 18:33:02

555

1

website: http://www.example.com @

2026-06-28 18:33:03

555

1

website: http://www.example.com @

2026-06-28 18:33:03

555

1

website: http://www.example.com @

2026-06-28 18:33:04

555

1

website: http://www.example.com @

2026-06-28 18:33:04

555

1

website: http://www.example.com @

2026-06-28 18:33:04

555

1

website: http://www.example.com @

2026-06-28 18:33:04

555

1

website: http://www.example.com @

2026-06-28 18:33:04

555

1

website: http://www.example.com @

2026-06-28 18:33:04

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:05

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:06

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:07

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.com @

2026-06-28 18:33:08

555

1

website: http://www.example.comh0ATGpi1 @

2026-06-28 18:33:09

555

1

website: http://www.example.com @

2026-06-28 18:33:09

555

1

website: -1 OR 5*525 -- @

2026-06-28 18:33:09

555

1

website: -1 OR 5*525 @

2026-06-28 18:33:09

555

1

website: -1' OR 5*525 -- @

2026-06-28 18:33:09

555

1

website: -1" OR 5*525 -- @

2026-06-28 18:33:09

555

1

website: -1' OR 5*525 or 'Fb7VpOFD'' @

2026-06-28 18:33:09

555

1

website: -1" OR 5*525 or "q64zncIi"" @

2026-06-28 18:33:09

555

1

website: if(now()sysdate(),sleep(15),0) @

2026-06-28 18:33:09

555

1

website: 2 @

2026-06-28 18:33:09

555

1

website: http://www.example.com-1 waitfor delay '0:0:15' -- @

2026-06-28 18:33:09

555
555

1

website: http://www.example.com @

2026-06-28 18:33:10

555

1

website: http://www.example.com'" @

2026-06-28 18:33:10

555

1

2026-06-28 18:33:10

555

1

website: @@JnDGI @

2026-06-28 18:33:10

555

1

website: (select 198766*667891) @

2026-06-28 18:33:10

555

1

website: (select 198766*667891 from DUAL) @

2026-06-28 18:33:10

555

1

website: http://www.example.com @

2026-06-28 18:56:13

555


Leave a Reply

Comment may not be visible immediately, because I process everything manually.**

**) I plan to automate this.., but it's on my ToDo since for ever..


Author:
Ray Burgemeestre
february 23th, 1984

Topics:
C++, Linux, Webdev

Other interests:
Music, Art, Zen